0
votes

I have a model with a auto-increment required int 'id'. And when I try to create a new record from server-script, I get 'id' field value is required, but found 'null'.

That's true I don't set this field. Because I assume it will be set by the the Cloud SQL instance behind that.

Am I doing wrong ?

[EDIT]

I have other tables with the same structure (a required int id auto-increment) and they work just fine. Setting 0 as a default value to this field produced Error: MySQL does not support zeros as the value of an auto-increment field. Setting 1 just replaced my previous record with id=1.

Something I did not say at first: in my app, this table used to be a view and so I was not able to create records from appmaker for it (and id was not primary key, nor auto-increment). I've changed my database schema, the table is now a proper table and the id field a proper id.
I made the changes in my Cloud SQL instance and then, from AppMaker, updated the app so it matches the database.

Could it be a problem from there ?

Thanks

2

2 Answers

1
votes

App Maker supports auto-increment for primary key field only. Other fields required to have non-null value on record creation if they're marked as required.

If NO_AUTO_VALUE_ON_ZERO is turned off (default) for the DB please try to default value to "0" for the field (in field's advanced settings).

0
votes

Creating new record, app maker will auto-generated a record to table. Without default value, it will return an error message.

I found this error message too what I did is to set Manual Save Mode in Datasource. After that you have to call Savechanges to save the records. Hope this help you :)