furious-luke/polecat

Refactor ORM

Closed this issue · 1 comments

Separate the abstract syntax tree for the query (Abstract Query Tree?) and the strategy used to construct the SQL. Use a Query base class, and Select, Insert, Update, and Delete subclasses. These should be concerned with only how they perform their operations in combination with subqueries. Use a "Q" class for combining queries that will require ordering/CTE-like combinations.

Make more use of the migration schema, as it will be invaluable for data migrations.

Tasks remaining:

  • Implement "delete" operations.
  • Write tests for common API operations (nested insert).
  • Filters.
  • Adding to returning clauses.
  • Table column reverses.
  • Implement model level queries.
  • Implement new migration system based on new schema.
  • Separate inserts and return queries.
  • Fix model update to use ID in provided model instance.
  • Remove old SQL generation, update GQL queries.
  • Update make migrations.

Instead of splitting inserts and selects, I'll substitute the insert queries over the table relationships. This limits the selections to only what was created, which I believe is what we really want. I should be able to add the substitute automatically when processing nested insert values in the query code.