kemalcr/kemal-session

Int64 Support

neovintage opened this issue · 6 comments

I'm using Postgres as a backend and user_id in my app is defined as Int64 (BigInt). That doesn't match up with context.session.int().

Thyra commented

We could easily implement a .int64 storage just like the others. If there is a need potential for many more additional data types I wouldn't like to spam the engines with all these single definitions, though; then we should find a smarter (maybe more abstract) solution.

PS: I chose Int32 for .int because it is the standard type so you don't always have to write 6_i64 etc.

@Thyra Throwing this out there.... Should we create an integer alias to handle Int32 | Int64? That way we could still write: context.session.int

An Int alias would be better. However is there any clash chance with other libraries since Int is pretty common.

Thyra commented

@neovintage I don't know, I have never worked with aliases, I'd have to look into this first. My main priority is that there is no additional complication for users who don't need Int64.

@Thyra I spent some time thinking about this. I don't see any other way to implement this other than creating a new method name. The alias will end up giving users a hard time that happen to be using Int32 everywhere in their code. Unfortunately, if we were to create context.session.int64, this opens kemal-session up to having to create method names for all of the primitives like Int8, Int16, UInt8, Float32, etc.

Any ideas on another abstraction?

Thyra commented

@neovintage In that case I would go for a bigint method and hope that the other data types are simply not needed.