-
Notifications
You must be signed in to change notification settings - Fork 115
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
Make PostgreSQL ready for Gramps 6.0 #638
base: maintenance/gramps60
Are you sure you want to change the base?
Conversation
""" | ||
self.__cursor.execute( | ||
"SELECT COUNT(*) FROM information_schema.columns " | ||
"WHERE table_name = %s AND column_name = %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does postgresql have this convention:
"WHERE table_name = %s AND column_name = %s", | |
"WHERE table_name = ? AND column_name = ?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what psycopg2 uses - it's like that in the rest of the addon as well.
By the way - since |
One of the many aspects we learn as we port to different engines 😄 In order for Postgresql to use a different type, we'll have to have an abstraction for that in the base class. Like:
and use that when we create the fields. There may be a couple of other abstractions if we have a generic SQL query method. I'll make a PR for the |
I may have misunderstood your question: I think Postgresql can use whatever type you want, as long as it acts like a string in Python. |
Actually, after reading up a bit, I realize I was making a wrong assumption - I thought the JSON type was more performant or offered more possibilities to query it, but it turns out it doesn't do much compared to TEXT, only enforcing JSON syntax, which we don't really need. So, nothing to do right now It will get more interesting/complicated if/when we start to query into the JSON structure itself, where each engine has their own syntax; like I had to do for the Sifts search library used in Gramps Web, e.g. https://github.com/DavidMStraub/sifts/blob/main/src/sifts/core.py#L428 |
That is on the schedule for 6.1 (soon!). We should coordinate now to make sure that whatever we do, that it works across at least postgresql and sqlite. Can you test this query in postgresql on new database structure: SELECT json_extract(json_data, '$.primary_name.surname_list[0].surname')
FROM person
WHERE (json_extract(json_data, '$.gender') = 0)
ORDER BY json_extract(json_data, '$.handle') DESC, json_extract(json_data, '$.gender'); That will be a good start. We'll have to check operators, but there is a test suite that I'll port to whatever approach we take. |
Sorry, but I have no capacity to check these things before the 6.0 release. Can we please not start new breaking database backend changes before 6.0 is fully released? |
|
I have not tested this yet. Will leave as draft until it's ready to merge.