Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarkic committed Apr 23, 2024
1 parent 0c90be9 commit e3ab381
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## main-dev (...)

- Added QuoteIdentifier attribute to support reserved database keywords for column names
- Improved error message in Model

## main-dev (2024-04-02)

Expand Down
12 changes: 8 additions & 4 deletions src/Model/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ function (Connection $connection) use ($arguments): QueryBuilder {
$source = $metadata->getSource();
$alias = $source->name;
$qb = new QueryBuilder($connection->query(), $this->meta);
$qb->fromArray([
'type' => 'SELECT',
...$arguments
]);
$qb->fromSource($source);
$select = array_map(
fn(Field $field) => $qb->selectField($field, $alias),
Expand All @@ -82,7 +86,7 @@ function (Connection $connection) use ($arguments): QueryBuilder {
);
/**
* order argument
*/
*
if (isset($arguments['order'])) {
if (is_array($arguments['order'])) {
foreach ($arguments['order'] as $order) {
Expand All @@ -98,7 +102,7 @@ function (Connection $connection) use ($arguments): QueryBuilder {
}
/**
* limit, offset argument
*/
*
if (isset($arguments['limit'])) {
if (is_array($arguments['limit'])) {
$limitArg = $arguments['limit'];
Expand All @@ -108,7 +112,7 @@ function (Connection $connection) use ($arguments): QueryBuilder {
$limit = isset($limitArg['limit']) ? (int)$limitArg['limit'] : null;
$offset = isset($limitArg['offset']) ? (int)$limitArg['offset'] : null;
$qb->limit($limit, $offset);
}
}*/
return $qb;
}
);
Expand Down Expand Up @@ -217,7 +221,7 @@ function (QueryBuilder $qb) use ($arguments): PromiseInterface {
foreach ($arguments as $fieldName => $fieldValue) {
$field = $metadata->getField($fieldName);
if ($field === null) {
return BadMethodCallException('No such field: ' . $fieldName . ' in model: ' . $model);
throw new BadMethodCallException('No such field: ' . $fieldName . ' in model: ' . $model);
}
$conditions[] = $qb->fieldCondition($field);
$parameters[] = $field->cast($fieldValue);
Expand Down
1 change: 1 addition & 0 deletions src/Model/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @method QueryBuilder limit(?int $offset = null, ?int $limit = null)
* @method QueryBuilder setParameters(array $params)
* @method QueryBuilder addParameter(mixed ...$param)
* @method QueryBuilder fromArray(array $data)
*/
class QueryBuilder implements LoggerAwareInterface
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Model/Attribute/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function testJsonSerialize()
',"name":"name","type":{"type":"int","min":0,"max":4294967295,' .
'"precision":null,"scale":null,"isNull":false,"options":null,' .
'"format":null,"field":null},"attributes":[null],"column":"name",' .
'"relation":null,"generatedValue":null}';
'"relation":null,"generatedValue":null,"quoteIdentifier":false}';
$this->assertSame($exp, json_encode($field));
}
}
3 changes: 2 additions & 1 deletion tests/Model/Attribute/SourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function testSourceWithSchema()

public function testJsonSerialize()
{
$exp = '{"attrName":"Blrf\\\\Orm\\\\Model\\\\Attribute\\\\Source","name":"name","schema":"schema"}';
$exp = '{"attrName":"Blrf\\\\Orm\\\\Model\\\\Attribute\\\\Source",' .
'"name":"name","schema":"schema","quoteIdentifier":false}';
$source = new Source('name', 'schema');
$this->assertSame($exp, json_encode($source));
}
Expand Down

0 comments on commit e3ab381

Please sign in to comment.