-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support collections (seq/set) #34
Comments
Thanks for the kind words, they really mean a lot to me 🙏 Are you suggesting mapping Nim enum type to Postgres enum? How should it be handled in SQLite? |
I'm suggesting you should support sequences and sets. Guess this would require creating a hidden extra table. |
Oh, you mean one to many relations represented? I thought about it but decided to keep models close to table schemas, so you define one to many with foreign keys as you would normally do in a table schema. However, Norm may be mature enough to provide a nicer interface for one to many relations. What if we add a proc that returns a seq if objects to types which are referenced as foreign keys in other types? Something like getMany that accepts two types, the "one" type and the "many" type. |
Nvm, I think I understand your proposal well enough now, my comment suggests a totally different story. |
Hello, thanks for your library. Will the seq be implemented soon ? |
Unlikely. Because I don't have a clear understanding how to represent seqs in SQL. Serializing and deserializing them sounds very expensive. And what if it's a seq of Model? How do I retrieve it from the DB? |
I understand, it's certainly not easy. A co-worker use Pony (Array https://docs.ponyorm.org/array.html) with Python. Maybe the code can help you. I hope :) |
@ArMour85 thanks for the link. I like Pony a lot and drew some inspiration from it (in fact, you can spot my quote on their website 🙂). They seem to have special types for collections that can be stored in DB. I guess we could go this path and add support for seq[SomeNumber] and the likes and store them as serialized json in SQLite maybe. In Postgres, there's a type for that (there's a type for everything apparently). |
This might be a bit off topic from the issue, but what I would like to see is handling an enum based field. Internally, this could map to just an integer (which means that reordering the enum fields would break stuff). Then, it would be really cool if you could query based on a set of enums. This might not be something you want within norm though - and that's fine - just thought I would throw it out there. |
@moigagoo @dom96 @ajusa If I'm understanding it right, that was the main point of the issue, right? I'm not 100% sure since I didn't try that one yet, but wouldn't this already be possible by defining a type alias and defining Given that, wouldn't it make sense to close this issue? |
This is a really awesome library! Thank you for putting it together.
One immediate thing I've tried is an object that contains a
set[EnumType]
, would love it if this worked out of the box.The text was updated successfully, but these errors were encountered: