Update to 2.0 create not working
Update to 2.0 create not working
We are updating to editor 2.0 and create is not working. In the debugSQL, the error (An SQL error occurred: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer: "") shows that the select statement after the create has a blank id instead of the newly created id.
{
"name": ":where_1",
"value": "",
"type": null
}
The database setup is unchanged, it is a postgres database and the id field has a sequence. I use this on several different tables, same result on all of them.
I haven't found anything in release notes to indicate any changes that would impact this.
Thanks in advance for any help.
This question has an accepted answers - jump to answer
Answers
Hi,
I'm not aware of any changes that would cause that error I'm afraid and it is passing our tests with Postgres. It sounds like the error is happening when trying to get the primary key value for the newly inserted row.
Could you show me your PHP and also the JSON return from the server when creating a new row?
Thanks,
Allan
Allan,
here is the json - seems to fail on the SELECT after the INSERT :
and here is the PHP:
Many thanks.
Could you change
Field::inst('application.id')
to be:please? (Assuming that you don't want it to writeable by the end user - just auto-generated by the database).
Allan
Allan,
That did the trick. I will do that on all auto-generated primary keys.
Allan,
I may have responded too quickly. The record is being created without an error, but the table is not refreshing. As you can see in the debug json, it is still not getting the proper parameters in the select statement after the create - the new id is not being valued correctly. Here is the new json:
The where_1 should be the newly created id.
Nevermind on the last question, it was an issue on one table related to the definition of the primary key in the database.