Invalid regex not reported as so

Author: nazneen84Created Sep 30, 2019Updated Nov 4, 2024

I tried a nested query. Instead of letting me know the regex is not valid or pointing out differences in the string literal versus the regex pattern, it said query not expected and unable to match actual versus expected query respectively.

Please clarify the regex was invalid in the panic message or a compile time warning please.

Stack overflow question here: https://stackoverflow.com/questions/58142191/call-to-query-with-args-was-not-expected-in-go-sqlmock-for-compound-sql-quer/58160875#58160875.

Example of working query:

sqlMock.ExpectQuery("SELECT EXISTS \\( SELECT 1 FROM information_schema\\.tables WHERE table_schema = 'public' AND table_name = 'myTable3' \\);").
        WillReturnRows(existsRows)

Example of Invalid query unable to match:

sqlMock.ExpectQuery("SELECT EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'myTable3' );").
        WillReturnRows(existsRows)

Example of invalid regex query skipped in evaulation:

sqlMock.ExpectQuery("SELECT EXISTS \\( SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'myTable3' \\);").
        WillReturnRows(existsRows)