-
Notifications
You must be signed in to change notification settings - Fork 174
Feature Request: Add support for using uuids as primary keys. #127
Comments
It looks like addition of this type would need to be included in the body of the following method: The following source files look as though they may also require modification: |
There is a Slack for Orator. So if you want to to be added to it drop me a DM on twitter with your email address and I will gladly do it. Regarding UUIDs in Orator, if you only need to read and write to the database, you can easily do it since UUIDs can be inserted and retrieved as strings. Now, if you want to create a column with the UUID type from Orator this is not currently supported but I will see if I can add it. |
Thank you. I was looking for binary UUID support because I think it would make indexing on UUIDs more efficient when being used as a primary key for a table. Looking at the source, it doesn’t seem like this would be a trivial feature to add, so I completely understand if it gets a low priority. Thank you for your consideration!
Byron
… On Dec 17, 2016, at 9:22 PM, Sébastien Eustace ***@***.***> wrote:
There is a Slack for Orator. So if you want to to be added to it drop me a DM on twitter <https://twitter.com/SDisPater> with your email address and I will gladly do it.
Regarding UUIDs in Orator, if you only need to read and write to the database, you can easily do it since UUIDs can be inserted and retrieved as strings.
Now, if you want to create a column with the UUID type from Orator this is not currently supported but I will see if I can add it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#127 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA-opMwd1dq_MqbR_Ch0zJ2koi_vwBb_ks5rJLUOgaJpZM4LP9oW>.
|
I am not sure I understand. What's the type of your column in PostgreSQL? |
The column type for the primary key is “uuid" with modifiers “not null default uuid_generate_v4()"
Here is an example:
… On Dec 17, 2016, at 9:52 PM, Sébastien Eustace ***@***.***> wrote:
I am not sure I understand. What's the type of your column in PostgreSQL?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#127 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA-opE6sBQ_SuAvUlIyxI0LzyCxPqxBLks5rJLwfgaJpZM4LP9oW>.
|
So, yes, you can pass a string to Orator as your ID and it will automatically be converted to a uuid. If you have a binary uuid column you can also pass a string and it should work. |
Maybe I am missing something, but the major advantage of uuid support (coming from Ruby/ActiveRecord) is that the database will generate its own uuid values automatically. If I used Orator with an auto-incrementing big integer as the primary key, it does not randomly generate a new uuid. That’s why I’m thinking that adding this feature would not be trivial. If I understand the situation correctly, it is currently possible to read and update records from tables that use uuids as the primary key, but creating a primary key for uuids would require using the big_integer type when defining the column type for the id column. It would also make sense to define a subclass of Model that overrides __init__() to generate a uuid upon initialization
BTW, thank you for taking the initiative to create an ORM package that makes it possible for a Rubyist ActiveRecord/Rails user to share an ORM database with a Python3 application/server. I really appreciate it. I’m still learning to use your package.
… On Dec 18, 2016, at 11:50 AM, Sébastien Eustace ***@***.***> wrote:
So, yes, you can pass a string to Orator as your ID and it will automatically be converted to a uuid. If you have a binary uuid column you can also pass a string and it should work.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#127 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA-opGeG9ESI2lzOmxzGkv3V2nCqCXg5ks5rJYB5gaJpZM4LP9oW>.
|
Okay. I understand now, sorry for being so slow. So, you are right it's not possible to create a uuid type from the schema builder without making it database backend dependent. I will look into it but, as you said, it will not be trivial. And, thanks for the kind words, I really appreciate it 😃 |
+1 |
I know it's a rough start but for use in my internal projects I implemented postgres uuid and overrode default to detect a gen_random_uuid() and not encapsulate it as a string. You can see the branch here: https://github.com/inventionlabsSydney/orator/tree/feature/PostgresGrammarSupportUuid I'd like @sdispater if you could provide me a list of things to do in order that we could merge this support into the actual project. |
PR in: #261 |
👍 |
I just discovered Orator last night. I'm a Rubyist that needs to mingle Python3 and Ruby in a project with a shared PostgreSQL database hosted locally. I use uuids as primary keys in the database. I haven't found a way to do this, so I am opening a feature request. Also, I haven't been able to find a discussion forum for Orator. Does one exist yet?
The text was updated successfully, but these errors were encountered: