sqlite-database-integration
sqlite-database-integration copied to clipboard
Support for `information_schema` tables
Queries to information_schema appear to succeed without errors, but they may not be returning correct results. I found out that there seems to be some rewriting done, but my guess is it may only be handling a few cases.
Checking for whether a table, column, or an index exist seems to return wrong result.
Here are the failing test cases:
public function testTableExists() {
$this->assertQuery( 'CREATE TABLE test (id INT)' );
$return = $this->assertQuery( "SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'test'" );
$this->assertEquals( [(object) ["1" => "1"]], $return );
}
public function testColumnExists() {
$this->assertQuery( 'CREATE TABLE test (id INT)' );
$return = $this->assertQuery( "SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'test' AND column_name = 'id'" );
$this->assertEquals( [(object) ["1" => "1"]], $return );
}
public function testIndexExists() {
$this->assertQuery( 'CREATE TABLE test (id INT)' );
$this->assertQuery( 'ALTER TABLE test ADD INDEX test_id_idx (id)' );
$return = $this->assertQuery( "SELECT 1 FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'test' AND index_name = 'test_id_idx'" );
$this->assertEquals( [(object) ["1" => "1"]], $return );
}
What is the status of information_schema support? Is it technically possible to rewrite all kinds of information schema queries, or would an easier approach be to create and manage the tables?