Skip to content

Conversation

@MasterOdin
Copy link
Member

Fixes #2330

PR fixes a bug where SQLiteAdapter::getColumns would throw an exception if the table had a column with a Literal type. This was due to a type error when passing the type of SQLiteAdapter::parseDefaultValue which requires the type be a string. While I could have modified parseDefaultValue to accept a string|Literal, as the function is defined as protected, this would have been a BC break, and so I went with converting the $type['name'] to a string in the caller (getColumns) instead.

$table = new Table('test', [], $this->adapter);
$columns = $table->getColumns();
$this->assertCount(1, $columns);
$this->assertEquals(Literal::from('decimal'), array_pop($columns)->getType());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DECIMAL is an accepted type, so ->getType() was returning "decimal", but since we were doing assertEquals, which equates to Literal::from('decimal') == 'decimal', the test was passing (as Literal was being converted to a string).

This is also why I added an assertion on the actual type of getType().

@MasterOdin MasterOdin merged commit 83bfbbe into 0.x Dec 3, 2024
12 checks passed
@MasterOdin MasterOdin deleted the fix-sqlite-litera branch December 3, 2024 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot get columns for sqlite with Literal column type

2 participants