Change param prefix from @ to :
This commit is contained in:
@@ -20,52 +20,52 @@ class QueryTest extends TestCase
|
||||
|
||||
public function testWhereByFieldsSucceedsForSingleField(): void
|
||||
{
|
||||
$this->assertEquals("data->>'test_field' <= @it",
|
||||
Query::whereByFields([Field::LE('test_field', '', '@it')]), 'WHERE fragment not constructed correctly');
|
||||
$this->assertEquals("data->>'test_field' <= :it",
|
||||
Query::whereByFields([Field::LE('test_field', '', ':it')]), 'WHERE fragment not constructed correctly');
|
||||
}
|
||||
|
||||
public function testWhereByFieldsSucceedsForMultipleFields(): void
|
||||
{
|
||||
$this->assertEquals("data->>'test_field' <= @it AND data->>'other_field' = @other",
|
||||
Query::whereByFields([Field::LE('test_field', '', '@it'), Field::EQ('other_field', '', '@other')]),
|
||||
$this->assertEquals("data->>'test_field' <= :it AND data->>'other_field' = :other",
|
||||
Query::whereByFields([Field::LE('test_field', '', ':it'), Field::EQ('other_field', '', ':other')]),
|
||||
'WHERE fragment not constructed correctly');
|
||||
}
|
||||
|
||||
public function testWhereByFieldsSucceedsForMultipleFieldsWithOr(): void
|
||||
{
|
||||
$this->assertEquals("data->>'test_field' <= @it OR data->>'other_field' = @other",
|
||||
Query::whereByFields([Field::LE('test_field', '', '@it'), Field::EQ('other_field', '', '@other')], 'OR'),
|
||||
$this->assertEquals("data->>'test_field' <= :it OR data->>'other_field' = :other",
|
||||
Query::whereByFields([Field::LE('test_field', '', ':it'), Field::EQ('other_field', '', ':other')], 'OR'),
|
||||
'WHERE fragment not constructed correctly');
|
||||
}
|
||||
|
||||
#[TestDox('Where by ID succeeds with default parameter')]
|
||||
public function testWhereByIdSucceedsWithDefaultParameter(): void
|
||||
{
|
||||
$this->assertEquals("data->>'id' = @id", Query::whereById(), 'WHERE fragment not constructed correctly');
|
||||
$this->assertEquals("data->>'id' = :id", Query::whereById(), 'WHERE fragment not constructed correctly');
|
||||
}
|
||||
|
||||
#[TestDox('Where by ID succeeds with specific parameter')]
|
||||
public function testWhereByIdSucceedsWithSpecificParameter(): void
|
||||
{
|
||||
$this->assertEquals("data->>'id' = @di", Query::whereById('@di'), 'WHERE fragment not constructed correctly');
|
||||
$this->assertEquals("data->>'id' = :di", Query::whereById(':di'), 'WHERE fragment not constructed correctly');
|
||||
}
|
||||
|
||||
public function testInsertSucceeds(): void
|
||||
{
|
||||
$this->assertEquals('INSERT INTO my_table VALUES (@data)', Query::insert('my_table'),
|
||||
$this->assertEquals('INSERT INTO my_table VALUES (:data)', Query::insert('my_table'),
|
||||
'INSERT statement not constructed correctly');
|
||||
}
|
||||
|
||||
public function testSaveSucceeds(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
"INSERT INTO test_tbl VALUES (@data) ON CONFLICT ((data->>'id')) DO UPDATE SET data = EXCLUDED.data",
|
||||
"INSERT INTO test_tbl VALUES (:data) ON CONFLICT ((data->>'id')) DO UPDATE SET data = EXCLUDED.data",
|
||||
Query::save('test_tbl'), 'INSERT ON CONFLICT statement not constructed correctly');
|
||||
}
|
||||
|
||||
public function testUpdateSucceeds()
|
||||
{
|
||||
$this->assertEquals("UPDATE testing SET data = @data WHERE data->>'id' = @id", Query::update('testing'),
|
||||
$this->assertEquals("UPDATE testing SET data = :data WHERE data->>'id' = :id", Query::update('testing'),
|
||||
'UPDATE statement not constructed correctly');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user