Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = crlf
; temporary
trim_trailing_whitespace = true
[*.php]
indent_style = spaces
indent_size = 4
insert_final_newline = true
[*.md]
indent_style = spaces
indent_size = 4
insert_final_newline = true
[vendor/**]
; Use editor default (possible autodetection).
indent_style =
indent_size =
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf

; temporary
trim_trailing_whitespace = true

[*.php]
indent_style = spaces
indent_size = 4
insert_final_newline = true

[*.md]
indent_style = spaces
indent_size = 4
insert_final_newline = true

[vendor/**]
; Use editor default (possible autodetection).
indent_style =
indent_size =
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
.phpunit.result.cache
.php-cs-fixer.cache
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

7 changes: 5 additions & 2 deletions src/Granada/ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,11 @@ public function select($column, $alias = null)
foreach ($columns as $column) {
if ($column == '*') {
if (!$this->_using_default_result_columns) {
// Put the * to the front of the list
$this->_result_columns = array_merge(['*'], $this->_result_columns);
// Check if we are already selecting '*'
if (($this->_result_columns[\array_key_first($this->_result_columns)] ?? '') != '*') {
// Put the * to the front of the list
$this->_result_columns = array_merge(['*'], $this->_result_columns);
}
}
} else {
$column = $this->_quote_identifier($column);
Expand Down
15 changes: 15 additions & 0 deletions tests/orm/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,21 @@ public function testSelectAsteriskColumn()
$this->assertEquals($expected, ORM::get_last_query());
}

public function testSelectAsteriskColumnTwice()
{
ORM::for_table('widget')->select('name')->find_many();
$expected = 'SELECT `name` FROM `widget`';
$this->assertEquals($expected, ORM::get_last_query());

ORM::for_table('widget')->select('name')->select('*')->select('*')->find_many();
$expected = 'SELECT *, `name` FROM `widget`';
$this->assertEquals($expected, ORM::get_last_query());

ORM::for_table('widget')->select('*')->select('*')->find_many();
$expected = 'SELECT * FROM `widget`';
$this->assertEquals($expected, ORM::get_last_query());
}

public function testSimpleResultColumn()
{
ORM::for_table('widget')->select('name')->find_many();
Expand Down