sqlite-jdbc
sqlite-jdbc copied to clipboard
Add support for default SQLite schemas
According to SQLite docs, there are at least two schemas supported: main and temp:
If a
schema-nameis specified, it must be either "main", "temp", or the name of an attached database. In this case the new table is created in the named database. If the "TEMP" or "TEMPORARY" keyword occurs between the "CREATE" and "TABLE" then the new table is created in the temp database. It is an error to specify both a schema-name and the TEMP or TEMPORARY keyword, unless theschema-nameis "temp". If no schema name is specified and the TEMP keyword is not present then the table is created in the main database.
Thus, two things need to happen for this JDBC driver to be compatible with SQLite (at least from this feature perspective):
- the
DatabaseMetadata#getSchemas()must return at least those two schemas (mainandtemp); hopefully the attached database too, but I am unsure if this is possible to determine at the relevant point in the code - the
DatabaseMetadata#supportsSchemasInTableDefinitions()must returntrueto indicate the consumers the table could be referenced either via its raw name or using a schema prefix
Currently the driver returns an empty result set for the DatabaseMetadata#getSchemas() and false for DatabaseMetadata#supportsSchemasInTableDefinitions(). This breaks some of the consumers (for instance, the applications using 3rd party APIs or the driver directly when trying to determine database schema at runtime).
#829 may be related