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
And this ends up causing ActiveRecord to issue 2 DB checks
Authorization Exists (1.2ms) SELECT 1 AS one FROM "authorizations" WHERE ("authorizations"."nonce" = 'test123' AND "authorizations"."client_application_id" = 1) LIMIT 1
Authorization Exists (1.1ms) SELECT 1 AS one FROM "authorizations" WHERE ("authorizations"."client_application_id" = 1 AND "authorizations"."nonce" = 'test123') LIMIT 1
Also, the "code" validations causes 2 queries to also be issued.
Authorization Exists (0.8ms) SELECT 1 AS one FROM "authorizations" WHERE "authorizations"."code" = $1 LIMIT 1 [["code", "040cd859525d7dcd42b4ab99fa7b23ae0d9ec0bc472a730874f2d810bd4ef0ec"]]
Authorization Exists (1.0ms) SELECT 1 AS one FROM "authorizations" WHERE "authorizations"."code" = '040cd859525d7dcd42b4ab99fa7b23ae0d9ec0bc472a730874f2d810bd4ef0ec' LIMIT 1
@urkle thanks for the report and sorry for the slow reply.
You're right, schema_validations ought to be able to optimize away those duplicate validations. Though I must admit I'm not certain whether there's complete symmetry between these two:
And agreed it's odd to have allow_nil when nil isn't allowed.
Unfortunately no time for me to dive into these right now--especially since there's a workaround: disable schema_validations for the offending column(s) and manually validate them appropriately--but PRs happily accepted!
I have this schema
Here is the list of validations generated
Notice the two validations created for the multi-column constraint. One for client_app_id, nonce.. And one for nonce, client_app_id
Also it seems odd that a validation with "allow_nil: true" would be generated when clearly I do not allow nils.
The text was updated successfully, but these errors were encountered: