Feedback on edgedb in the context of python #5122
Replies: 5 comments
-
Hi @arogozhnikov! Thanks a lot for posting feedback, appreciate it! I took the liberty to re-post your Gist above as it'll hopefully be more convenient to lead the discussion here and easier to find for others. Some comments in threads below. |
Beta Was this translation helpful? Give feedback.
-
I guess this could be a discoverability issue. EdgeDB does have equivalents for views and CTEs, we call them expression aliases, which can be declared both at the schema level:
and at the query level:
(the last example is from my 1.0 release day talk) |
Beta Was this translation helpful? Give feedback.
-
This mostly stems from the (current) lack of proper Python query builder (which is fair, because you evaluated in the context of Python). You can do this with the JavaScript binding:
|
Beta Was this translation helpful? Give feedback.
-
It's a 3.0 feature, which has not been released yet. There is a lot of new migration-related features coming in 3.0, the docs are being written now. |
Beta Was this translation helpful? Give feedback.
-
This is a great suggestion! The current codegen is basically v1.0, there's definitely lots of room for making it better. Please don't hesitate to open issues in edgedb-python. |
Beta Was this translation helpful? Give feedback.
-
Hi edgedb team,
I've evaluated edgedb for my purposes, and decided in favor of sqlmodel/sqlachemy2.
There are multiple improvements in edgedb over plain postgres that attract me, but there is also a number of show-stoppers as well. I think this kind of feedback should be helpful.
I've compiled my summary in this gist: https://gist.github.com/arogozhnikov/41b6ac59fbe094a574ea016c271a7868
Feel free to comment and correct me if I missed something.
Notes on edgedb
I’ve made a test evaluation of edgedb for the purposes of a small company.
My order of priorities (starting from most important):
Setup that I compare to:
postgresql on AWS aurora (managed with AWS CDK) +
sqlalchemy
+sqlmodel
+alembic
EdgeDB provides a number of significant improvements over reference setup:
Downsides:
there is no way to migrate down (undo migration).
I use it quite often, and don’t want to clutter history with experiments.
(migrating down mostly happens in local and dev stages)
Migration rewrite is undocumented. Github discussion did not help me at all.
edgedb website really pushes on composability of edgeql, i.e. you can ‘nest’ one query into another (like in graphQL).
While the statement is correct, my understanding of composability includes ability to name some piece of code and refer to it by name.
In other words, composability is useful when you can decompose into parts and combine them.
SQL has temporary tables, views, common table expression - all far from being great tools, but to some degree they satisfy this requirement; edgeql queries don't.
Another example of composability:
ORMs can define some expression, and then pass it to outer scope, where expression can be narrowed down by subselecting for data required in this context.
I don’t see a similar tool in edgedb/edgeql - queries are isolated and can't be combined.
Python client. That’s the biggest point, and edgedb loses to sqlalchemy/sqlmodel here.
Official examples (e.g. for Flask) commonly use inline queries, which
Both points are a significant downgrade from sqlalchemy2/sqlmodel.
Another available option is code generation. Queries written in .edgeql are wrapped into python code with proper typing.
This addresses previous problems: code generation verifies query against the schema, and typing is available.
Inconveniently, every query should be its own file.
Code generation however does not reduce amount of code you need to write.
To insert/update/upsert/select by id, you need to write a query with all parameters typed.
I like that parameters are typed, but why can’t I just have it autogenerated from schema?
This could be just a number of typed functions
create_movie(id: Optional[uuid], title: str, …)
,update_movie(id: uuid, title: Optional[str]=NoValue, …)
Or even embrace TypedDicts to map objects to deliver help with typing inputs/outputs without ORMs and classes.
As a result, most common operations require a significant hassle in edgedb.
Comments:
Well, if I used typescript, I'd probably compare with prisma.
It simpolifies onboarding of new developers as they don't need to install any tools.
Editor, on the other hand is not as convenient/advanced as e.g. IntelliJ's solutions.
Beta Was this translation helpful? Give feedback.
All reactions