You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The native column attributes implementation introduced in #48357 has broken inserts using Postgres models with guarded attributes and column names matching PostgreSQL reserved words in my application.
The compileColumns() query in the Postgres schema grammar makes use of PostgreSQL's quote_ident() function which quotes reserves words.
SELECT quote_ident('foo') as value; -> foo SELECT quote_ident('end') as value; -> "end"
This is causing the GuardsAttributes trait to improperly detect fillable columns.
Changing select quote_ident(a.attname) as name to select a.attname as name in the Postgres Grammar resolves the issue, but I'm not sure if there are other downstream consequences to that.
Ex:
Given a table like the following:
Schema::create('my_table', function (Blueprint$table) {
$table->id();
$table->string('label');
$table->timestamp('start');
$table->timestamp('end');
$table->boolean('analyze');
});
The output of Schema::getColumns('my_table'); is the following.
Seems like a side-effect of this fix is that the compileColumns query now appears in tools like debugbar. It may be a "cosmetic issue" only, but in the debugbar timeline those queries not only appear but seem to be a bit slower than the rest.
Laravel Version
10.30.0
PHP Version
8.2.11
Database Driver & Version
PostgreSQL 15.1
Description
The native column attributes implementation introduced in #48357 has broken inserts using Postgres models with guarded attributes and column names matching PostgreSQL reserved words in my application.
The
compileColumns()
query in the Postgres schema grammar makes use of PostgreSQL'squote_ident()
function which quotes reserves words.SELECT quote_ident('foo') as value;
->foo
SELECT quote_ident('end') as value;
->"end"
This is causing the
GuardsAttributes
trait to improperly detect fillable columns.Changing
select quote_ident(a.attname) as name
toselect a.attname as name
in the Postgres Grammar resolves the issue, but I'm not sure if there are other downstream consequences to that.Ex:
Given a table like the following:
The output of
Schema::getColumns('my_table');
is the following.Steps To Reproduce
Fails with error...
Passes under Laravel 10.29.0.
The text was updated successfully, but these errors were encountered: