Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive SQL error #1304

Closed
hugorouty opened this issue Jul 24, 2024 · 10 comments
Closed

False positive SQL error #1304

hugorouty opened this issue Jul 24, 2024 · 10 comments
Assignees
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring-data-support theme: validation type: bug

Comments

@hugorouty
Copy link

hugorouty commented Jul 24, 2024

Hello,

It seems that the bug mentioned last month (#1274) returns with the new v1.56.0 upgrade.
Since this morning I have hundreds of errors on my VSCode Spring Boot project, I just reverted to v1.55.1 and all the errors have disappeared...

This is my problems panel on VSCode, filtered on "errors" :

With v1.55.1 :
image

With 1.56.0 :
image

There are two different errors:
image

First is :
image
PostgreSQL: no viable alternative at input ':user'vscode-spring-boot(SQL_SYNTAX)

Second error type is :
image

PostgreSQL: mismatched input '<EOF>' expecting {WHITESPACE, A_, ABORT, ABS, ABSOLUTE, ACCESS, ACTION, ADA, ADD, ADMIN, AFTER, AGGREGATE, ALLOCATE, ALSO, ALTER, ALWAYS, ANALYZE, ANY, ARE, ASENSITIVE, ASSERTION, ASSIGNMENT, AT, ATOMIC, ATTRIBUTE, ATTRIBUTES, AVG, BACKWARD, BEFORE, BEGIN, BERNOULLI, BETWEEN, BIGINT, BIT, BIT_LENGTH, BLOB, BOOLEAN, BREADTH, BY, C_, CACHE, CALL, CALLED, CARDINALITY, CASCADE, CASCADED, CATALOG, CATALOG_NAME, CEIL, CEILING, CHAIN, CHAR, CHAR_LENGTH, CHARACTER, CHARACTER_LENGTH, CHARACTER_SET_CATALOG, CHARACTER_SET_NAME, CHARACTER_SET_SCHEMA, CHARACTERISTICS, CHARACTERS, CHECKPOINT, CLASS, CLASS_ORIGIN, CLOB, CLOSE, CLUSTER, COALESCE, COBOL, COLLATION_CATALOG, COLLATION_NAME, COLLATION_SCHEMA, COLLECT, COLUMN_NAME, COMMAND_FUNCTION, COMMAND_FUNCTION_CODE, COMMENT, COMMIT, COMMITTED, CONDITION, CONDITION_NUMBER, CONNECT, CONNECTION, CONNECTION_NAME, CONSTRAINT_CATALOG, CONSTRAINT_NAME, CONSTRAINT_SCHEMA, CONSTRAINTS, CONSTRUCTOR, CONTAINS, CONTINUE, CONVERSION, CONVERT, COPY, CORR, CORRESPONDING, COUNT, COVAR_POP, COVAR_SAMP, CREATE, CSV, CUBE, CUME_DIST, CURRENT, CURRENT_DEFAULT_TRANSFORM_GROUP, CURRENT_PATH, CURRENT_TRANSFORM_GROUP_FOR_TYPE, CURSOR, CURSOR_NAME, CYCLE, DATA, DATABASE, DATE, DATETIME_INTERVAL_CODE, DATETIME_INTERVAL_PRECISION, DAY, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULTS, DEFERRED, DEFINED, DEFINER, DEGREE, DELETE, DELIMITER, DELIMITERS, DENSE_RANK, DEPTH, DEREF, DERIVED, DESCRIBE, DESCRIPTOR, DETERMINISTIC, DIAGNOSTICS, DICTIONARY, DISCARD, DISCONNECT, DISPATCH, DOMAIN, DOUBLE, DROP, DYNAMIC, DYNAMIC_FUNCTION, DYNAMIC_FUNCTION_CODE, EACH, ELEMENT, ENCODING, ENCRYPTED, END, EQUALS, ESCAPE, EVERY, EXCEPTION, EXCLUDE, EXCLUDING, EXCLUSIVE, EXEC, EXECUTE, EXISTS, EXP, EXPLAIN, EXTENSION, EXTERNAL, EXTRACT, FILTER, FINAL, FIRST, FLOAT, FLOOR, FOLLOWING, FORCE, FORMAT, FORTRAN, FORWARD, FOUND, FREE, FUNCTION, FUSION, G_, GENERAL, GENERATED, GET, GLOBAL, GO, GOTO, GRANTED, GREATEST, GROUPING, HANDLER, HIERARCHY, HOLD, HOST, HOUR, IDENTITY, IGNORE, IMMEDIATE, IMMUTABLE, IMPLEMENTATION, IMPLICIT, INCLUDING, INCREMENT, INDEX, INDICATOR, INHERITS, INOUT, INPUT, INSENSITIVE, INSERT, INSTANCE, INSTANTIABLE, INSTEAD, INT, INTEGER, INTERSECTION, INTERVAL, INVOKER, ISOLATION, K_, KEY, KEY_MEMBER, KEY_TYPE, LANGUAGE, LARGE, LAST, LEAST, LEFT, LENGTH, LEVEL, LISTEN, LN, LOAD, LOCAL, LOCATION, LOCATOR, LOCK, LOCKED, LOWER, M_, MAP, MATCH, MATCHED, MAX, MAXVALUE, MEMBER, MERGE, MESSAGE_LENGTH, MESSAGE_OCTET_LENGTH, MESSAGE_TEXT, METHOD, MIN, MINUTE, MINVALUE, MOD, MODE, MODIFIES, MODULE, MONTH, MORE_, MOVE, MULTISET, MUMPS, NAME, NAMES, NATIONAL, NCHAR, NCLOB, NESTING, NEW, NEXT, NO, NONE, NORMALIZE, NORMALIZED, NOTHING, NOTIFY, NOWAIT, NULLABLE, NULLIF, NULLS, NUMBER, NUMERIC, OBJECT, OCTET_LENGTH, OCTETS, OF, OFF, OIDS, OLD, OPEN, OPERATOR, OPTION, OPTIONS, ORDERING, ORDINALITY, OTHERS, OUT, OUTPUT, OVER, OVERLAY, OVERRIDING, OWNER, PAD, PARAMETER, PARAMETER_MODE, PARAMETER_NAME, PARAMETER_ORDINAL_POSITION, PARAMETER_SPECIFIC_CATALOG, PARAMETER_SPECIFIC_NAME, PARAMETER_SPECIFIC_SCHEMA, PARTIAL, PARTITION, PASCAL, PASSWORD, PATH, PERCENT_RANK, PERCENTILE_CONT, PERCENTILE_DISC, PLAIN, PLI, POSITION, POWER, PRECEDING, PRECISION, PREPARE, PRESERVE, PRIOR, PRIVILEGES, PROCEDURAL, PROCEDURE, PUBLIC, QUOTE, RANGE, RANK, READ, READS, REAL, REASSIGN, RECHECK, RECURSIVE, REF, REFERENCING, REFRESH, REGR_AVGX, REGR_AVGY, REGR_COUNT, REGR_INTERCEPT, REGR_SLOPE, REGR_SXX, REGR_SXY, REGR_SYY, REINDEX, RELATIVE, RELEASE, RENAME, REPEATABLE, REPLACE, RESET, RESTART, RESTRICT, RESULT, RETURN, RETURNED_CARDINALITY, RETURNED_LENGTH, RETURNED_OCTET_LENGTH, RETURNED_SQLSTATE, RETURNS, REVOKE, RIGHT, ROLE, ROLLBACK, ROLLUP, ROUTINE, ROUTINE_CATALOG, ROUTINE_NAME, ROUTINE_SCHEMA, ROW, ROW_COUNT, ROW_NUMBER, ROWS, RULE, SAVEPOINT, SCALE, SCHEMA, SCHEMA_NAME, SCOPE, SCOPE_CATALOG, SCOPE_NAME, SCOPE_SCHEMA, SCROLL, SEARCH, SECOND, SECTION, SECURITY, SELECT, SELF, SENSITIVE, SEQUENCE, SEQUENCES, SERIALIZABLE, SERVER_NAME, SESSION, SET, SETOF, SETS, SHARE, SHOW, SIMPLE, SIZE, SMALLINT, SOME, SOURCE, SPACE, SPECIFIC, SPECIFIC_NAME, SPECIFICTYPE, SQL, SQLCODE, SQLERROR, SQLEXCEPTION, SQLSTATE, SQLWARNING, SQRT, STABLE, START, STATE, STATEMENT, STATIC, STATISTICS, STDDEV_POP, STDDEV_SAMP, STDIN, STDOUT, STORAGE, STRICT, STRUCTURE, STYLE, SUBCLASS_ORIGIN, SUBMULTISET, SUBSTRING, SUM, SYSID, SYSTEM, SYSTEM_USER, TABLE, TABLE_NAME, TABLESPACE, TEMP, TEMPLATE, TEMPORARY, TIES, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE, TOP_LEVEL_COUNT, TRANSACTION, TRANSACTION_ACTIVE, TRANSACTIONS_COMMITTED, TRANSACTIONS_ROLLED_BACK, TRANSFORM, TRANSFORMS, TRANSLATE, TRANSLATION, TREAT, TRIGGER, TRIGGER_CATALOG, TRIGGER_NAME, TRIGGER_SCHEMA, TRIM, TRUE, TRUNCATE, TRUSTED, TYPE, UESCAPE, UNBOUNDED, UNCOMMITTED, UNDER, UNENCRYPTED, UNKNOWN, UNLISTEN, UNNAMED, UNNEST, UNTIL, UPDATE, UPPER, USAGE, USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_CODE, USER_DEFINED_TYPE_NAME, USER_DEFINED_TYPE_SCHEMA, VACUUM, VALID, VALIDATOR, VALUE, VALUES, VAR_POP, VAR_SAMP, VARCHAR, VARYING, VIEW, VOLATILE, WHENEVER, WIDTH_BUCKET, WITH, WITHIN, WITHOUT, WORK, WRITE, YEAR, ZONE, ABSTIME, BIGSERIAL, BIT_VARYING, BOOL, BOX, BYTEA, CHARACTER_VARYING, CIDR, CIRCLE, FLOAT4, FLOAT8, INET, INT2, INT4, INT8, JSON, JSONB, LINE, LSEG, MACADDR, MACADDR8, MONEY, PG_LSN, POINT, POLYGON, RELTIME, SERIAL, SERIAL2, SERIAL4, SERIAL8, SMALLSERIAL, TEXT, TIMESTAMPTZ, TIMETZ, TSQUERY, TSVECTOR, TXID_SNAPSHOT, UUID, VARBIT, XML, '(', DOUBLEQ_STRING_LITERAL, IDENTIFIER, IDENTIFIER_UNICODE}vscode-spring-boot(SQL_SYNTAX)

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Jul 24, 2024

@hugorouty rather than revert to 1.55.1 turn off SQL queries validations here:

Screenshot 2024-07-24 at 10 22 45

@BoykoAlex
Copy link
Contributor

The only difference from 1.55.1 is that the default problem severity from IGNORE has changed to ERROR since we had more confidence in the parser as we now have a dedicated PostgreSQL ANTLR parser... but looks like we were too optimistic

@BoykoAlex
Copy link
Contributor

The issue is the ; at the end... are you sure this is the right syntax?

@BoykoAlex
Copy link
Contributor

@hugorouty Looks like ; is needed between statements. The parser seemed to be more strict in this case and doesn't allow for ; if the statement isn't followed by another statement. I can make the parser not as strict about it.

Do you mind pasting more queries with syntax errors? Looks like you have lots of them... I'm just curious to learn if there are more cases beyond ';' that require fixes. If you happen to have a link to a git repo with the project you're looking at it'd be even better :-) Thanks in advance!

@BoykoAlex
Copy link
Contributor

I have fixed ; at the end of the first statement issue with 2b91b4c but likely there are others which I'd like to explore as well

@hugorouty
Copy link
Author

@BoykoAlex

Thanks for the fix, I usually write and test my queries in a Datagrip console so I usually add; at the end of each.
I will check during the day if I found others issues, but I can't share you the git repo it's a professional project (even table and column names are changed in shared queries).

@BoykoAlex BoykoAlex self-assigned this Jul 28, 2024
@BoykoAlex BoykoAlex added this to the 4.25.0.RELEASE milestone Jul 28, 2024
@vchrisb
Copy link

vchrisb commented Jul 29, 2024

I get an error when using a Param

  @Query(
    nativeQuery = true,
    value = "SELECT * FROM cards ORDER BY random() LIMIT :limit"
  )
  Set<Card> getRandomCards(@Param("limit") Integer number);

PostgreSQL: mismatched input 'LIMIT' expecting {, ';'}

When replacing :limit with an integer, the error goes away.

@BoykoAlex
Copy link
Contributor

@vchrisb Thanks for pasting the snippet. Seems like the issue is in the ANTLR parser grammar, namely clauses where parameter is expected. Will get this fixed

@martinlippert martinlippert added for: eclipse something that is specific for Eclipse theme: spring-data-support for: vscode something that is specific for VSCode theme: validation and removed status: waiting-for-triage labels Jul 30, 2024
@BoykoAlex
Copy link
Contributor

BoykoAlex commented Jul 30, 2024

@vchrisb Fixed with 2b7ac1a. Added support for more places to accept parameters. Interesting that parameter accepts reserved keyword limit... I ensured however that it is accepted becausew I trust this query works and worked for a long time ;-) However, there might be more reserved words that I'm missing so we'll add them gradually over time.
Keeping opened for now for more PSQL snippets with parse errors.
You can give it a try with a snapshot build from: https://cdn.spring.io/spring-tools/snapshot/STS4/nightly-distributions.html

@martinlippert
Copy link
Member

Closing this for the upcoming 4.25.0 release now. Let's capture additional new findings in a separate new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring-data-support theme: validation type: bug
Projects
None yet
Development

No branches or pull requests

4 participants