You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to test if I get the same tables when running .sync({force: true}) and when using the migration process. I am using in-memory SQLite tables for that. I thought that I would be able to query sqlite_master special table and compare the sql column. However, since this table is schema-less, it seems that there is a bit of magic behind it.
SELECT * FROM sqlite_master will return names. SELECT sql FROM sqlite_master will return undefined for each row. SELECT 1 FROM sqlite_master will also return undefined for each row.
After digging a bit, I can workaround the special case by using a view. This is fine for me but maybe this special case is not needed anymore. Remains from sqlite2?
I believe the reason for skipping pragma if querying sqlite_master is that sqlite_master is used internally, so not querying pragma each time saves space. However, the current implementation queries other tables for pragma, each time a query is made to those tables, so I don't know how much we are really saving.
The reason we are even using PRAGMA is to get the column types so we can parse the data correctly btw.
@vincentbernat Do you want to take a stab at modifying sqlite/query and adding a couple of tests. The don't have to be migrator specific, perhaps just testing that you can query sqlite_master and get the expected result
Activity
mickhansen commentedon Apr 9, 2014
I don't really know that much about sqlite, but googling gave me this: http://www.sqlite.org/faq.html#q7
It appears you need to use multiple queries, one to get name from sqlite master, and then something like:
But honestly i don't know, this is very sqlite specific - Not so much sequelize ;)
mickhansen commentedon Apr 9, 2014
From what i'm reading
SELECT * FROM sqlite_master;should give you sql as well, but again, i have no idea.vincentbernat commentedon Apr 9, 2014
There is some code to handle this table in sequelize. See here:
https://github.com/sequelize/sequelize/blob/b1f666e9663791f0fe7ec7e8335d472515731d69/lib/dialects/sqlite/query.js
I said previously that this table was schema-less but it is not:
So, why the special case?
vincentbernat commentedon Apr 9, 2014
After digging a bit, I can workaround the special case by using a view. This is fine for me but maybe this special case is not needed anymore. Remains from sqlite2?
vincentbernat commentedon Apr 9, 2014
For reference, here is my test: https://gist.github.com/vincentbernat/10239464
While there is no guarantee for columns ordering, this currently works as expected.
db: add unittests for migration
janmeier commentedon Apr 14, 2014
I believe the reason for skipping pragma if querying sqlite_master is that sqlite_master is used internally, so not querying pragma each time saves space. However, the current implementation queries other tables for pragma, each time a query is made to those tables, so I don't know how much we are really saving.
The reason we are even using PRAGMA is to get the column types so we can parse the data correctly btw.
@vincentbernat Do you want to take a stab at modifying sqlite/query and adding a couple of tests. The don't have to be migrator specific, perhaps just testing that you can query sqlite_master and get the expected result
janmeier commentedon Apr 8, 2015
Closing this issue, since it is neither a bug report nor a feature request.
For general sequelize questions, please use StackOverflow or Google groups.