sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

issues-179 Add support for view

Open ikrivosheev opened this issue 3 years ago • 10 comments

PR Info

Depends on:

  • https://github.com/SeaQL/sea-query/pull/436

Adds

Add support for: create, delete, rename VIEW.

TODO:

  • [x] add backends
  • [ ] add tests
  • [ ] add docs

ikrivosheev avatar Apr 04 '22 17:04 ikrivosheev

I need more time for support backends, because SQLite, MySQL and Postgres are very different in the details.

ikrivosheev avatar Apr 04 '22 18:04 ikrivosheev

@tyt2y3 @billy1624, hello. POC for support VIEW is done (without docs and tests). I have one question: ViewCreateStatement has field: query which is SelectStatement. For transform SelectStatement to SQL needed impl QueryStatementBuilder on the other hand: ViewDropStatement does not needed QueryStatementBuilder (only SchemaStatementBuilder).

What to do? In impl ViewStatement everywhere return (String, Values) or is there something better?

ikrivosheev avatar Apr 05 '22 20:04 ikrivosheev

@tyt2y3 @billy1624 any ideas?

ikrivosheev avatar Apr 10 '22 19:04 ikrivosheev

Hey @ikrivosheev, sorry for the delay. What a huge PR loll

Notice a few things. For, create view:

  • OR REPLACE is supported by MySQL, MariaDB and PostgreSQL, SQLite wasn't supported
  • However, IF NOT EXISTS is supported by SQLite but not the other three db
  • TEMPORARY is supported by PostgreSQL and SQLite but not the other two db
  • RECURSIVE is supported only by PostgreSQL
  • WITH [ CASCADED | LOCAL ]...

And, the list goes on. I think it's better to document these db specific features later in this PR. Or, even, dump some of the feature that supported by only one db.

References:

  • https://dev.mysql.com/doc/refman/8.0/en/create-view.html
  • https://mariadb.com/kb/en/create-view/
  • https://www.postgresql.org/docs/current/sql-createview.html
  • https://www.sqlite.org/lang_createview.html

I understood this. My question was: https://github.com/SeaQL/sea-query/pull/293#issuecomment-1089338484

ikrivosheev avatar Apr 26 '22 09:04 ikrivosheev

I think ViewCreateStatement should impl QueryStatementBuilder. May be we can forget ViewStatement for now, if we do keep it then all methods should return (String, Values)

tyt2y3 avatar Apr 26 '22 14:04 tyt2y3

status?

ian-p-cooke avatar Oct 07 '22 11:10 ian-p-cooke

status?

@ian-p-cooke hello! I am working on support Postgres array in SeaQuery. After I will return back to this PR.

ikrivosheev avatar Oct 07 '22 11:10 ikrivosheev

Well, It's time to continue working on this PR.

ikrivosheev avatar Dec 26 '22 12:12 ikrivosheev

Any news on this?

LucaRickler avatar Aug 05 '23 09:08 LucaRickler