Skip to content
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

Improvements suggestions #50

Open
Oreilles opened this issue May 17, 2021 · 7 comments
Open

Improvements suggestions #50

Oreilles opened this issue May 17, 2021 · 7 comments

Comments

@Oreilles
Copy link
Contributor

Oreilles commented May 17, 2021

  • Add schema and comment support in tableInfo and columnInfo for all vendors
  • Add primary information in tableInfo
  • Add is_view information in tableInfo and stop filtering them out
  • Delegate name aliasing and type conversion to the database query to bypass conversion from RawColumn to Column
  • Refactor knex queries to raw SQL to improve readability when appropriate
  • Unify test between vendors
  • Move table creation SQL code to test specs.

Opinion? 🥬

@gpetrov
Copy link

gpetrov commented May 17, 2021

Initially I was for using Knex queries wherever possible, but this turned a bit to more a hack with all those Knex raw mixtures.

Eventually it is all raw queries, so we might just enter them directly instead double translating then through Knex.

@rijkvanzanten
Copy link
Collaborator

Fully agree with @gpetrov here! The only perks to the Knex approach are the conditional "if A then query.where(A)" thingies, but those should be easy enough to refactor too.

For the other points:

✅ Add schema and comment support in tableInfo and columnInfo for all vendors

(for the vendors that support them. IIRC MySQL doesn't differentiate between schema/database, and sqlite doesn't have comments f.e.)

✅ Add primary information in tableInfo
✅ Add is_view information in tableInfo and stop filtering them out
✅ Delegate name aliasing and type conversion to the database query to bypass conversion from RawColumn to Column

The only reason it isn't like that right now is my lack of knowledge of all the specific SQL casting stuff in the different vendors 😁

✅ Refactor knex queries to raw SQL to improve readability when appropriate
❓ Unify test between vendors

Mind clarifying what you mean by unify in this case?

✅ Move table creation SQL code to test specs.

@Oreilles
Copy link
Contributor Author

Oreilles commented May 17, 2021

IIRC MySQL doesn't differentiate between schema/database

It's just that the default schema in MySQL is named after its database, instead of being named public like others vendors - but it behaves exactly like them.

Mind clarifying what you mean by unify in this case?

Creating the exact same table configuration in each database so the expected result from each test can be shared (and maybe also database initialization if we move it to knex) to avoid code duplication, and reduce chances of error when adding a new feature (like the generated attribute, or upcoming is_view ).

The only reason it isn't like that right now is my lack of knowledge of all the specific SQL casting stuff in the different vendors 😁

Okay, I'll get to it 👍

@rijkvanzanten
Copy link
Collaborator

Awesome! Thank you @Oreilles ❤️

@rijkvanzanten
Copy link
Collaborator

It's just that the default schema in MySQL is named after its database, instead of being named public like others vendors - but it behaves exactly like them.

Are you sure about that? From MySQL's reference manual:

In MySQL, physically, a schema is synonymous with a database. You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.

Some other database products draw a distinction. For example, in the Oracle Database product, a schema represents only a part of a database: the tables and other objects owned by a single user.

As far as I can tell, MySQL treats SCHEMA == DATABASE and schema's don't have behavioral characteristics you'd find in the other vendors 🤔

@Oreilles
Copy link
Contributor Author

Oreilles commented May 17, 2021

OK, that's weird... It means that their concept of a database is different than others. (You can't query table from a database while being in another one in other vendors, but apparently with MySQL you can - because it behaves like a schema).

@rijkvanzanten
Copy link
Collaborator

So it'd be better to say that they don't support databases, but only support schemas? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants