Skip to content

Commit

Permalink
Merge branch 'JSQLParser:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
qzchenwl authored Jun 26, 2022
2 parents 6e40662 + c1c38fe commit 85aa098
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,12 @@ public void testMultiValueIn4() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void selectIsolationKeywordsAsAlias() throws JSQLParserException {
String stmt = "SELECT col FROM tbl cs";
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void testMultiValueInBinds() throws JSQLParserException {
String stmt = "SELECT * FROM mytable WHERE (a, b) IN ((?, ?), (?, ?))";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
-- #%L
-- JSQLParser library
-- %%
-- Copyright (C) 2004 - 2022 JSQLParser
-- %%
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
-- #L%
---
DECLARE
PK_NAME VARCHAR(200);

BEGIN
EXECUTE IMMEDIATE ('CREATE SEQUENCE "untitled_table3_seq"');

SELECT
cols.column_name INTO PK_NAME
FROM
all_constraints cons,
all_cons_columns cols
WHERE
cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
AND cols.table_name = 'untitled_table3';

execute immediate (
'create or replace trigger "untitled_table3_autoinc_trg" BEFORE INSERT on "untitled_table3" for each row declare checking number := 1; begin if (:new."' || PK_NAME || '" is null) then while checking >= 1 loop select "untitled_table3_seq".nextval into :new."' || PK_NAME || '" from dual; select count("' || PK_NAME || '") into checking from "untitled_table3" where "' || PK_NAME || '" = :new."' || PK_NAME || '"; end loop; end if; end;'
);
END

--@FAILURE: Encountered unexpected token: "PK_NAME" <S_IDENTIFIER> recorded first on May 27, 2022, 10:27:41 PM

This comment has been minimized.

Copy link
@manticore-projects

manticore-projects Jun 26, 2022

Contributor

Please why exactly are we adding Failing Test Cases?
I would like to prefer added tests of features only, which failed before, have been corrected since and will pass now.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
-- #%L
-- JSQLParser library
-- %%
-- Copyright (C) 2004 - 2022 JSQLParser
-- %%
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
-- #L%
---
DECLARE
n_emp_id EMPLOYEES.EMPLOYEE_ID%TYPE := &emp_id1;
BEGIN
DECLARE
n_emp_id employees.employee_id%TYPE := &emp_id2;
v_name employees.first_name%TYPE;
BEGIN
SELECT first_name, CASE foo WHEN 'a' THEN 1 ELSE 2 END CASE as other
INTO v_name
FROM employees
WHERE employee_id = n_emp_id;

DBMS_OUTPUT.PUT_LINE('First name of employee ' || n_emp_id ||
' is ' || v_name);
EXCEPTION
WHEN no_data_found THEN
DBMS_OUTPUT.PUT_LINE('Employee ' || n_emp_id || ' not found');
END;
END

--@FAILURE: Encountered unexpected token: "n_emp_id" <S_IDENTIFIER> recorded first on May 27, 2022, 10:29:48 PM
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
-- #%L
-- JSQLParser library
-- %%
-- Copyright (C) 2004 - 2022 JSQLParser
-- %%
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0
-- #L%
---
BEGIN
SELECT
cols.column_name INTO :variable
FROM
example_table;
END

--@FAILURE: Encountered unexpected token: "BEGIN" "BEGIN" recorded first on May 27, 2022, 10:29:48 PM

1 comment on commit 85aa098

@wumpz
Copy link
Member

@wumpz wumpz commented on 85aa098 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. However correct the parser to parse this and and passing test cases. Collect all in a proper PR.

Please sign in to comment.