thrownewInvalidArgumentException('primary or replica configuration missing');
}
...
...
@@ -133,7 +138,10 @@ class PrimaryReadReplicaConnection extends Connection
publicfunctionconnect($connectionName=null)
{
if($connectionName!==null){
thrownewInvalidArgumentException('Passing a connection name as first argument is not supported anymore. Use ensureConnectedToPrimary()/ensureConnectedToReplica() instead.');
thrownewInvalidArgumentException(
'Passing a connection name as first argument is not supported anymore.'
.' Use ensureConnectedToPrimary()/ensureConnectedToReplica() instead.'
@@ -472,9 +472,13 @@ class SqlitePlatform extends AbstractPlatform
*/
publicfunctiongetListTablesSQL()
{
return"SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' AND name != 'geometry_columns' AND name != 'spatial_ref_sys' "
.'UNION ALL SELECT name FROM sqlite_temp_master '
."WHERE type = 'table' ORDER BY name";
return'SELECT name FROM sqlite_master'
." WHERE type = 'table'"
." AND name != 'sqlite_sequence'"
." AND name != 'geometry_columns'"
." AND name != 'spatial_ref_sys'"
.' UNION ALL SELECT name FROM sqlite_temp_master'
." WHERE type = 'table' ORDER BY name";
}
/**
...
...
@@ -508,8 +512,18 @@ class SqlitePlatform extends AbstractPlatform
$sql[]=sprintf('CREATE TEMPORARY TABLE %s AS SELECT %s FROM %s',$dataTable->getQuotedName($this),implode(', ',$oldColumnNames),$table->getQuotedName($this));
$sql[]=sprintf('INSERT INTO %s (%s) SELECT %s FROM %s',$newTable->getQuotedName($this),implode(', ',$newColumnNames),implode(', ',$oldColumnNames),$dataTable->getQuotedName($this));
$sql[]=sprintf(
'INSERT INTO %s (%s) SELECT %s FROM %s',
$newTable->getQuotedName($this),
implode(', ',$newColumnNames),
implode(', ',$oldColumnNames),
$dataTable->getQuotedName($this)
);
$sql[]=$this->getDropTableSQL($dataTable);
$newName=$diff->getNewName();
...
...
@@ -994,10 +1038,16 @@ class SqlitePlatform extends AbstractPlatform
@@ -440,22 +449,22 @@ class DataAccessTest extends FunctionalTestCase
$row=$this->connection->fetchAssociative($sql);
$row=array_change_key_case($row,CASE_LOWER);
self::assertEquals('2010-01-01 10:10:11',date('Y-m-d H:i:s',strtotime($row['add_seconds'])),'Adding second should end up on 2010-01-01 10:10:11');
self::assertEquals('2010-01-01 10:10:09',date('Y-m-d H:i:s',strtotime($row['sub_seconds'])),'Subtracting second should end up on 2010-01-01 10:10:09');
self::assertEquals('2010-01-01 10:15:10',date('Y-m-d H:i:s',strtotime($row['add_minutes'])),'Adding minutes should end up on 2010-01-01 10:15:10');
self::assertEquals('2010-01-01 10:05:10',date('Y-m-d H:i:s',strtotime($row['sub_minutes'])),'Subtracting minutes should end up on 2010-01-01 10:05:10');
self::assertEquals('2010-01-01 13:10',date('Y-m-d H:i',strtotime($row['add_hour'])),'Adding date should end up on 2010-01-01 13:10');
self::assertEquals('2010-01-01 07:10',date('Y-m-d H:i',strtotime($row['sub_hour'])),'Subtracting date should end up on 2010-01-01 07:10');
self::assertEquals('2010-01-11',date('Y-m-d',strtotime($row['add_days'])),'Adding date should end up on 2010-01-11');
self::assertEquals('2009-12-22',date('Y-m-d',strtotime($row['sub_days'])),'Subtracting date should end up on 2009-12-22');
self::assertEquals('2010-01-08',date('Y-m-d',strtotime($row['add_weeks'])),'Adding week should end up on 2010-01-08');
self::assertEquals('2009-12-25',date('Y-m-d',strtotime($row['sub_weeks'])),'Subtracting week should end up on 2009-12-25');
self::assertEquals('2010-03-01',date('Y-m-d',strtotime($row['add_month'])),'Adding month should end up on 2010-03-01');
self::assertEquals('2009-11-01',date('Y-m-d',strtotime($row['sub_month'])),'Subtracting month should end up on 2009-11-01');
self::assertEquals('2010-10-01',date('Y-m-d',strtotime($row['add_quarters'])),'Adding quarters should end up on 2010-04-01');
self::assertEquals('2009-04-01',date('Y-m-d',strtotime($row['sub_quarters'])),'Subtracting quarters should end up on 2009-10-01');
self::assertEquals('2016-01-01',date('Y-m-d',strtotime($row['add_years'])),'Adding years should end up on 2016-01-01');
self::assertEquals('2004-01-01',date('Y-m-d',strtotime($row['sub_years'])),'Subtracting years should end up on 2004-01-01');
$sql='SELECT modify_limit_table.test_int FROM modify_limit_table INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ORDER BY modify_limit_table.test_int DESC';
$sql='SELECT modify_limit_table.test_int'
.' FROM modify_limit_table'
.' INNER JOIN modify_limit_table2'
.' ON modify_limit_table.test_int = modify_limit_table2.test_int'
.' ORDER BY modify_limit_table.test_int DESC';
$this->assertLimitResult([2,2,1,1,1],$sql,10,0);
$this->assertLimitResult([1,1,1],$sql,3,2);
...
...
@@ -120,7 +124,8 @@ class ModifyLimitQueryTest extends FunctionalTestCase
@@ -474,8 +480,11 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$c=newComparator();
$diff=$c->diffTable($tableFrom,$tableTo);
self::assertInstanceOf(TableDiff::class,$diff,'There should be a difference and not false being returned from the table comparison');
self::assertSame(['ALTER TABLE autoinc_type_modification ALTER id TYPE '.$expected],$this->connection->getDatabasePlatform()->getAlterTableSQL($diff));
self::assertInstanceOf(TableDiff::class,$diff);
self::assertSame(
['ALTER TABLE autoinc_type_modification ALTER id TYPE '.$expected],
self::assertEquals('SIMILAR TO',$this->platform->getRegexpExpression(),'Regular expression operator is not correct');
self::assertEquals('"',$this->platform->getIdentifierQuoteCharacter(),'Identifier quote character is not correct');
self::assertEquals('column1 || column2 || column3',$this->platform->getConcatExpression('column1','column2','column3'),'Concatenation expression is not correct');
self::assertEquals('SUBSTRING(column FROM 5)',$this->platform->getSubstringExpression('column',5),'Substring expression without length is not correct');
self::assertEquals('SUBSTRING(column FROM 1 FOR 5)',$this->platform->getSubstringExpression('column',1,5),'Substring expression with length is not correct');
self::assertEquals('"',$this->platform->getIdentifierQuoteCharacter(),'Identifier quote character is not correct');
self::assertEquals('column1 || column2 || column3',$this->platform->getConcatExpression('column1','column2','column3'),'Concatenation expression is not correct');
$sql=$this->platform->modifyLimitQuery('SELECT * FROM user',10,10);
self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a WHERE ROWNUM <= 20) WHERE doctrine_rownum >= 11',$sql);
self::assertEquals(
'SELECT * FROM ('
.'SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a WHERE ROWNUM <= 20'
@@ -327,7 +341,17 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$targets=[
sprintf('CREATE TABLE %s (%s NUMBER(10) NOT NULL)',$tableName,$columnName),
sprintf(
"DECLARE constraints_Count NUMBER; BEGIN SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = '%s' AND CONSTRAINT_TYPE = 'P'; IF constraints_Count = 0 OR constraints_Count = '' THEN EXECUTE IMMEDIATE 'ALTER TABLE %s ADD CONSTRAINT %s_AI_PK PRIMARY KEY (%s)'; END IF; END;",
'DECLARE constraints_Count NUMBER;'
.' BEGIN'
.' SELECT COUNT(CONSTRAINT_NAME)'
.' INTO constraints_Count'
.' FROM USER_CONSTRAINTS'
." WHERE TABLE_NAME = '%s' AND CONSTRAINT_TYPE = 'P';"
." IF constraints_Count = 0 OR constraints_Count = ''"
@@ -335,7 +359,20 @@ class OraclePlatformTest extends AbstractPlatformTestCase
),
sprintf('CREATE SEQUENCE %s_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1',$tableName),
sprintf(
"CREATE TRIGGER %s_AI_PK BEFORE INSERT ON %s FOR EACH ROW DECLARE last_Sequence NUMBER; last_InsertID NUMBER; BEGIN SELECT %s_SEQ.NEXTVAL INTO :NEW.%s FROM DUAL; IF (:NEW.%s IS NULL OR :NEW.%s = 0) THEN SELECT %s_SEQ.NEXTVAL INTO :NEW.%s FROM DUAL; ELSE SELECT NVL(Last_Number, 0) INTO last_Sequence FROM User_Sequences WHERE Sequence_Name = '%s_SEQ'; SELECT :NEW.%s INTO last_InsertID FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP SELECT %s_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; END LOOP; END IF; END;",
'CREATE TRIGGER %s_AI_PK BEFORE INSERT ON %s FOR EACH ROW DECLARE last_Sequence NUMBER;'
.' last_InsertID NUMBER;'
.' BEGIN SELECT %s_SEQ.NEXTVAL'
.' INTO :NEW.%s FROM DUAL;'
.' IF (:NEW.%s IS NULL OR :NEW.%s = 0)'
.' THEN SELECT %s_SEQ.NEXTVAL INTO :NEW.%s FROM DUAL;'
.' ELSE SELECT NVL(Last_Number, 0) INTO last_Sequence'
." FROM User_Sequences WHERE Sequence_Name = '%s_SEQ';"
.' SELECT :NEW.%s INTO last_InsertID FROM DUAL;'
.' WHILE (last_InsertID > last_Sequence) LOOP'
.' SELECT %s_SEQ.NEXTVAL INTO last_Sequence FROM DUAL;'
.' END LOOP;'
.' END IF;'
.' END;',
$tableName,
$tableName,
$tableName,
...
...
@@ -443,10 +480,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
@@ -177,7 +177,11 @@ class QueryBuilderTest extends TestCase
->orWhere('u.name = ?')
->andWhere('u.name = ?');
self::assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)',(string)$qb);
self::assertEquals(
'SELECT u.*, p.* FROM users u'
.' WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)',
(string)$qb
);
}
publicfunctiontestSelectGroupBy():void
...
...
@@ -279,7 +283,10 @@ class QueryBuilderTest extends TestCase
->having('u.name = ?')
->andHaving('u.username = ?');
self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)',(string)$qb);
self::assertEquals(
'SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)',
(string)$qb
);
}
publicfunctiontestSelectHavingOrHaving():void
...
...
@@ -293,7 +300,10 @@ class QueryBuilderTest extends TestCase
->having('u.name = ?')
->orHaving('u.username = ?');
self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)',(string)$qb);
self::assertEquals(
'SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)',
(string)$qb
);
}
publicfunctiontestSelectOrHavingOrHaving():void
...
...
@@ -307,7 +317,10 @@ class QueryBuilderTest extends TestCase
->orHaving('u.name = ?')
->orHaving('u.username = ?');
self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)',(string)$qb);
self::assertEquals(
'SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)',
(string)$qb
);
}
publicfunctiontestSelectHavingAndOrHaving():void
...
...
@@ -322,7 +335,10 @@ class QueryBuilderTest extends TestCase
->orHaving('u.username = ?')
->andHaving('u.username = ?');
self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)',(string)$qb);
self::assertEquals(
'SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)',
(string)$qb
);
}
publicfunctiontestSelectOrderBy():void
...
...
@@ -679,7 +695,10 @@ class QueryBuilderTest extends TestCase
->where('nt.lang = :lang AND n.deleted != 1');
$this->expectException(QueryException::class);
$this->expectExceptionMessage("The given alias 'invalid' is not part of any FROM or JOIN clause table. The currently registered aliases are: news, nv.");
$this->expectExceptionMessage(
"The given alias 'invalid' is not part of any FROM or JOIN clause table. "
.'The currently registered aliases are: news, nv.'
);
self::assertEquals('',$qb->getSQL());
}
...
...
@@ -695,7 +714,13 @@ class QueryBuilderTest extends TestCase
->where('nt.lang = ?')
->andWhere('n.deleted = 0');
self::assertEquals("SELECT COUNT(DISTINCT news.id) FROM newspages news INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)",$qb->getSQL());
self::assertEquals(
'SELECT COUNT(DISTINCT news.id) FROM newspages news'
." INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News'"
.' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id'
.' INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)',
@@ -710,7 +735,13 @@ class QueryBuilderTest extends TestCase
->where('u.id = a.user_id')
->andWhere('p.read = 1');
self::assertEquals('SELECT DISTINCT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles a INNER JOIN comments c ON c.article_id = a.id WHERE (u.id = a.user_id) AND (p.read = 1)',$qb->getSQL());
self::assertEquals(
'SELECT DISTINCT u.id FROM users u'
.' INNER JOIN permissions p ON p.user_id = u.id, articles a'
@@ -814,7 +845,13 @@ class QueryBuilderTest extends TestCase
->where('users.id = articles.user_id')
->andWhere('p.read = 1');
self::assertEquals('SELECT DISTINCT users.id FROM users INNER JOIN permissions p ON p.user_id = users.id, articles INNER JOIN comments c ON c.article_id = articles.id WHERE (users.id = articles.user_id) AND (p.read = 1)',$qb->getSQL());
self::assertEquals(
'SELECT DISTINCT users.id FROM users'
.' INNER JOIN permissions p ON p.user_id = users.id, articles'
.' INNER JOIN comments c ON c.article_id = articles.id'
.' WHERE (users.id = articles.user_id) AND (p.read = 1)',
self::assertEquals('SELECT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles INNER JOIN comments c ON c.article_id = articles.id',$qb->getSQL());
self::assertEquals(
'SELECT u.id FROM users u'
.' INNER JOIN permissions p ON p.user_id = u.id, articles'
.' INNER JOIN comments c ON c.article_id = articles.id',
['SELECT @rank := 1 AS rank, :foo AS foo FROM :bar',[27=>'foo',44=>'bar']],// Ticket DBAL-398
['SELECT * FROM Foo WHERE bar > :start_date AND baz > :start_date',[30=>'start_date',52=>'start_date']],// Ticket GH-113
['SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date',[46=>'start_date',68=>'start_date']],// Ticket GH-259
['SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1',[57=>'param1']],// Ticket DBAL-552
['SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1',[57=>'param1']],// Ticket DBAL-552
// Ticket GH-113
[
'SELECT * FROM Foo WHERE bar > :start_date AND baz > :start_date',
[
30=>'start_date',
52=>'start_date',
],
],
// Ticket GH-259
[
'SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date',
[
46=>'start_date',
68=>'start_date',
],
],
// Ticket DBAL-552
[
'SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1',
[57=>'param1'],
],
// Ticket DBAL-552
['SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1',[57=>'param1']],
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])',[56=>'foo']],// Ticket GH-2295
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])',[56=>'foo']],
['SELECT table.column1, ARRAY[\'3\'] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']',[74=>'foo']],
['SELECT table.column1, ARRAY[\'3\']::integer[] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']::integer[]',[85=>'foo']],
['SELECT table.column1, ARRAY[:foo] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']',[28=>'foo',75=>'bar']],
['SELECT table.column1, ARRAY[:foo]::integer[] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']::integer[]',[28=>'foo',86=>'bar']],
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])',[56=>'foo']],[
'SELECT table.column1, ARRAY[\'3\'] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']',
[74=>'foo'],
],
[
'SELECT table.column1, ARRAY[\'3\']::integer[] FROM schema.table table'
.' WHERE table.f1 = :foo AND ARRAY[\'3\']::integer[]',
[85=>'foo'],
],
[
'SELECT table.column1, ARRAY[:foo] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']',
[
28=>'foo',
75=>'bar',
],
],
[
'SELECT table.column1, ARRAY[:foo]::integer[] FROM schema.table table'
.' WHERE table.f1 = :bar AND ARRAY[\'3\']::integer[]',
[
28=>'foo',
86=>'bar',
],
],
[
<<<'SQLDATA'
SELECT * FROM foo WHERE
...
...
@@ -91,12 +138,60 @@ SQLDATA
190=>'a_param3',
],
],
["SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE '\\\\') AND (data.description LIKE :condition_1 ESCAPE '\\\\') ORDER BY id ASC",[121=>'condition_0',174=>'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE "\\\\") ORDER BY id ASC',[121=>'condition_0',174=>'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC',[121=>'condition_0',174=>'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`) AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC',[121=>'condition_0',174=>'condition_1']],
['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\') AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC',[121=>'condition_0',174=>'condition_1']],
["SELECT * FROM Foo WHERE (foo.bar LIKE :condition_0 ESCAPE '\') AND (foo.baz = :condition_1) AND (foo.bak LIKE :condition_2 ESCAPE '\')",[38=>'condition_0',78=>'condition_1',110=>'condition_2']],
[
'SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data'
." WHERE (data.description LIKE :condition_0 ESCAPE '\\\\')"
." AND (data.description LIKE :condition_1 ESCAPE '\\\\') ORDER BY id ASC",
[
121=>'condition_0',
174=>'condition_1',
],
],
[
'SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data'
.' WHERE (data.description LIKE :condition_0 ESCAPE "\\\\")'
.' AND (data.description LIKE :condition_1 ESCAPE "\\\\") ORDER BY id ASC',
[
121=>'condition_0',
174=>'condition_1',
],
],
[
'SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data'
.' WHERE (data.description LIKE :condition_0 ESCAPE "\\\\")'
.' AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC',
[
121=>'condition_0',
174=>'condition_1',
],
],
[
'SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data'
.' WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`)'
.' AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC',
[
121=>'condition_0',
174=>'condition_1',
],
],
[
'SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data'
.' WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\')'
.' AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC',
[
121=>'condition_0',
174=>'condition_1',
],
],
[
"SELECT * FROM Foo WHERE (foo.bar LIKE :condition_0 ESCAPE '\')"
." AND (foo.baz = :condition_1) AND (foo.bak LIKE :condition_2 ESCAPE '\')",
['RTRIM','a','CREATE TABLE "a" ("a" text DEFAULT "aa" COLLATE "RTRIM" NOT NULL)'],
['utf-8','a','CREATE TABLE "a" ("b" text UNIQUE NOT NULL COLLATE NOCASE, "a" text DEFAULT "aa" COLLATE "utf-8" NOT NULL)'],
['NOCASE','a','CREATE TABLE "a" ("a" text DEFAULT (lower(ltrim(" a") || rtrim("a "))) CHECK ("a") NOT NULL COLLATE NOCASE UNIQUE, "b" text COLLATE RTRIM)'],
[null,'a','CREATE TABLE "a" ("a" text CHECK ("a") NOT NULL, "b" text COLLATE RTRIM)'],
['RTRIM','a"b','CREATE TABLE "a" ("a""b" text COLLATE RTRIM)'],
['BINARY','b','CREATE TABLE "a" (bb TEXT COLLATE RTRIM, b VARCHAR(42) NOT NULL COLLATE BINARY)'],
['BINARY','b','CREATE TABLE "a" (bbb TEXT COLLATE NOCASE, bb TEXT COLLATE RTRIM, b VARCHAR(42) NOT NULL COLLATE BINARY)'],
['BINARY','b','CREATE TABLE "a" (b VARCHAR(42) NOT NULL COLLATE BINARY, bb TEXT COLLATE RTRIM)'],
['utf-8','bar#','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, "bar#" VARCHAR(255) COLLATE "utf-8" NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))'],
[null,'bar#','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, "bar#" VARCHAR(255) NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'],
['utf-8','baz','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, "bar#" INTEGER NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))'],
[null,'baz','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, "bar#" INTEGER NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'],
['utf-8','bar/','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, "bar/" VARCHAR(255) COLLATE "utf-8" NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))'],
[null,'bar/','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, "bar/" VARCHAR(255) NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'],
['utf-8','baz','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, "bar/" INTEGER NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))'],
[null,'baz','CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, "bar/" INTEGER NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'],
[
'RTRIM',
'a',
'CREATE TABLE "a" ("a" text DEFAULT "aa" COLLATE "RTRIM" NOT NULL)',
],
[
'utf-8',
'a',
'CREATE TABLE "a" ("b" text UNIQUE NOT NULL COLLATE NOCASE, '
.'"a" text DEFAULT "aa" COLLATE "utf-8" NOT NULL)',
],
[
'NOCASE',
'a',
'CREATE TABLE "a" ("a" text DEFAULT (lower(ltrim(" a") || rtrim("a ")))'
.' CHECK ("a") NOT NULL COLLATE NOCASE UNIQUE, "b" text COLLATE RTRIM)',
],
[
null,
'a',
'CREATE TABLE "a" ("a" text CHECK ("a") NOT NULL, "b" text COLLATE RTRIM)',
],
[
'RTRIM',
'a"b',
'CREATE TABLE "a" ("a""b" text COLLATE RTRIM)',
],
[
'BINARY',
'b',
'CREATE TABLE "a" (bb TEXT COLLATE RTRIM, b VARCHAR(42) NOT NULL COLLATE BINARY)',
],
[
'BINARY',
'b',
'CREATE TABLE "a" (bbb TEXT COLLATE NOCASE, bb TEXT COLLATE RTRIM, '
.'b VARCHAR(42) NOT NULL COLLATE BINARY)',
],
[
'BINARY',
'b',
'CREATE TABLE "a" (b VARCHAR(42) NOT NULL COLLATE BINARY, bb TEXT COLLATE RTRIM)',
],
[
'utf-8',
'bar#',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, '
.'"bar#" VARCHAR(255) COLLATE "utf-8" NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, '
.'PRIMARY KEY(id))',
],
[
null,
'bar#',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL,'
.' "bar#" VARCHAR(255) NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))',
],
[
'utf-8',
'baz',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL,'
.' "bar#" INTEGER NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))',
],
[
null,
'baz',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, "bar#" INTEGER NOT NULL, '
.'baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))',
],
[
'utf-8',
'bar/',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, '
.'"bar/" VARCHAR(255) COLLATE "utf-8" NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL,'
.' PRIMARY KEY(id))',
],
[
null,
'bar/',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL, '
.'"bar/" VARCHAR(255) NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))',
],
[
'utf-8',
'baz',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) COLLATE "utf-8" NOT NULL, '
.'"bar/" INTEGER NOT NULL, baz VARCHAR(255) COLLATE "utf-8" NOT NULL, PRIMARY KEY(id))',
],
[
null,
'baz',
'CREATE TABLE dummy_table (id INTEGER NOT NULL, foo VARCHAR(255) NOT NULL,'
.' "bar/" INTEGER NOT NULL, baz VARCHAR(255) NOT NULL, PRIMARY KEY(id))',
],
];
}
...
...
@@ -83,13 +160,15 @@ class SqliteSchemaManagerTest extends TestCase
'Multiple similar columns with type comment 1'=>[
null,
'b',
'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" TEXT DEFAULT "a" COLLATE RTRIM, "bb" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" TEXT DEFAULT "a" COLLATE RTRIM, '
$this->expectExceptionMessage("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'");
$this->expectExceptionMessage(
"Could not convert database value to 'array' as an error was triggered by the unserialization:"
$this->expectExceptionMessage("Could not convert database value to 'object' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'");
$this->expectExceptionMessage(
"Could not convert database value to 'object' as an error was triggered by the unserialization:"