Add in/inArray; expand Field ctr func names
This commit is contained in:
@@ -35,7 +35,7 @@ class CountTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals("SELECT COUNT(*) FROM somewhere WHERE data->>'errors' > :errors",
|
||||
Count::byFields('somewhere', [Field::GT('errors', 10, ':errors')]),
|
||||
Count::byFields('somewhere', [Field::greater('errors', 10, ':errors')]),
|
||||
'SELECT statement not generated correctly');
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ class DeleteTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals("DELETE FROM my_table WHERE data->>'value' < :max AND data->>'value' >= :min",
|
||||
Delete::byFields('my_table', [Field::LT('value', 99, ':max'), Field::GE('value', 18, ':min')]),
|
||||
Delete::byFields('my_table',
|
||||
[Field::less('value', 99, ':max'), Field::greaterOrEqual('value', 18, ':min')]),
|
||||
'DELETE statement not constructed correctly');
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class ExistsTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals("SELECT EXISTS (SELECT 1 FROM box WHERE data->>'status' <> :status)",
|
||||
Exists::byFields('box', [Field::NE('status', 'occupied', ':status')]),
|
||||
Exists::byFields('box', [Field::notEqual('status', 'occupied', ':status')]),
|
||||
'Existence query not generated correctly');
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class FindTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals("SELECT data FROM there WHERE data->>'active' = :act OR data->>'locked' = :lock",
|
||||
Find::byFields('there', [Field::EQ('active', true, ':act'), Field::EQ('locked', true, ':lock')],
|
||||
Find::byFields('there', [Field::equal('active', true, ':act'), Field::equal('locked', true, ':lock')],
|
||||
FieldMatch::Any),
|
||||
'SELECT query not generated correctly');
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class PatchTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
$this->assertEquals("UPDATE that SET data = data || :data WHERE (data->>'something')::numeric < :some",
|
||||
Patch::byFields('that', [Field::LT('something', 17, ':some')]), 'Patch UPDATE statement is not correct');
|
||||
Patch::byFields('that', [Field::less('something', 17, ':some')]), 'Patch UPDATE statement is not correct');
|
||||
}
|
||||
|
||||
#[TestDox('By fields succeeds for SQLite')]
|
||||
@@ -61,7 +61,8 @@ class PatchTest extends TestCase
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals(
|
||||
"UPDATE a_table SET data = json_patch(data, json(:data)) WHERE data->>'something' > :it",
|
||||
Patch::byFields('a_table', [Field::GT('something', 17, ':it')]), 'Patch UPDATE statement is not correct');
|
||||
Patch::byFields('a_table', [Field::greater('something', 17, ':it')]),
|
||||
'Patch UPDATE statement is not correct');
|
||||
}
|
||||
|
||||
public function testByFieldsFailsWhenModeNotSet(): void
|
||||
|
||||
@@ -76,7 +76,7 @@ class RemoveFieldsTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
$this->assertEquals("UPDATE enchilada SET data = data - :sauce::text[] WHERE data->>'cheese' = :queso",
|
||||
RemoveFields::byFields('enchilada', [Field::EQ('cheese', 'jack', ':queso')],
|
||||
RemoveFields::byFields('enchilada', [Field::equal('cheese', 'jack', ':queso')],
|
||||
Parameters::fieldNames(':sauce', ['white'])),
|
||||
'UPDATE statement not correct');
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class RemoveFieldsTest extends TestCase
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
$this->assertEquals(
|
||||
"UPDATE chimichanga SET data = json_remove(data, :filling0) WHERE data->>'side' = :rice",
|
||||
RemoveFields::byFields('chimichanga', [Field::EQ('side', 'beans', ':rice')],
|
||||
RemoveFields::byFields('chimichanga', [Field::equal('side', 'beans', ':rice')],
|
||||
Parameters::fieldNames(':filling', ['beef'])),
|
||||
'UPDATE statement not correct');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user