Skip to content

Commit 611527d

Browse files
committed
Update forced query type tests
1 parent dc5dd51 commit 611527d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,68 @@ public void mixQueryExceptionTest() throws SQLException {
108108
"SELECT * FROM test_table;\n\tCREATE TABLE test_table (id int, value text);"
109109
);
110110
}
111+
112+
@Test
113+
public void forsedTypeTest() throws SQLException {
114+
YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, QueryType.SCHEME_QUERY);
115+
116+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
117+
"CREATE TABLE test_table (id int, value text)"
118+
));
119+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
120+
"\tcreate TABLE test_table2 (id int, value text);"
121+
));
122+
123+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
124+
" drop TABLE test_table1 (id int, value text);" +
125+
"ALTER TABLE test_table2 (id int, value text);"
126+
));
127+
128+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
129+
"SELECT id, value FROM test_table"
130+
));
131+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
132+
"UPSERT INTO test_table VALUES (?, ?)"
133+
));
134+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
135+
"DELETE FROM test_table"
136+
));
137+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
138+
"SELECT id, value FROM test_table;\n" +
139+
"UPSERT INTO test_table VALUES (?, ?);" +
140+
"DELETE FROM test_table"
141+
));
142+
143+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
144+
"SELECT id, value FROM test_table;\n" +
145+
"UPDATE test_table SET value = ? WHERE id = ?;" +
146+
"SELECT id, value FROM test_table WHERE id=CREATE"
147+
));
148+
149+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
150+
"SCAN SELECT id, value FROM test_table"
151+
));
152+
153+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
154+
"EXPLAIN SELECT id, value FROM test_table"
155+
));
156+
157+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
158+
"CREATE TABLE test_table (id int, value text);" +
159+
"SELECT * FROM test_table;"
160+
));
161+
162+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
163+
"DROP TABLE test_table (id int, value text);SELECT * FROM test_table;"
164+
));
165+
166+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
167+
"SELECT * FROM test_table;CREATE TABLE test_table (id int, value text);"
168+
));
169+
170+
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
171+
"SELECT * FROM test_table;\n\tCREATE TABLE test_table (id int, value text);"
172+
));
173+
}
174+
111175
}

0 commit comments

Comments
 (0)