Closed pavelsr closed 4 years ago
Ah. Looks like JSON::Validator is saying that the object is invalid because created
is missing. That is probably a bug in read_schema
: A column that is NOT NULL
is marked as required
in the validator, but I don't think I check to see if it also has a DEFAULT
(which would make it no longer required, since the database will solve the NOT NULL
problem).
So, the fix is to make sure that the validator doesn't fail on missing NOT NULL
fields that will have a default generated by the database.
As a temporary workaround, the magic string "now" might work to bypass validation: app->yancy->create( users => { username => "admin", password => "admin", created => "now" } );
As another temporary workaround, invoking the backend's method skips validation (but it then also skips filters and schema-defined defaults, so YMMV): app->yancy->backend->create( users => { username => "admin", password => "admin" } );
->backend
is ok. magic string "now" is not working, same Error validating new item in schema "users": (/created)
error.
My Yancy version is 1.047
By the way, yancy->backend->create
insert password in plain so it's impossible to use this workaround in practise.
Sorry, yes, I forgot that bypasses the filters as well, which is how the digests work... I'm working on reproducing the problem and hope to have a fix soon.
I can't seem to reproduce the error with the Yancy unit tests. Could you send me a dump of the JSON schema of the users schema? You can get it by doing:
./myapp.pl eval -V 'app->yancy->schema( "users" )'
Possible duplicate/clarification of issue #79
E.g. I have table
I set
read_schema => 1
in Yancy config and try to executeIf I not provide
created
explicitly via Perl, likecreated => '2019-01-01 14:45:12'
there will be an error:Seems like yancy.validate not produce any @errors but for some reason failed.
Is it possible to get verbose description of error ? Is that issue related to Mojo::mysql or JSON::Validator?
As temporary solution I generate CURRENT_TIMESTAMP via POSIX::strftime(), like
print strftime "%Y-%m-%d %H:%M:%S", localtime time
, but still, any way to leave handling timestamp for SQL ?