[libgda/LIBGDA_5.2] GdaParser: remove spaces and enters before next statement
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_5.2] GdaParser: remove spaces and enters before next statement
- Date: Sat, 30 Nov 2019 13:55:55 +0000 (UTC)
commit 5762856924f743e10cf37deb5656362862f991d4
Author: Daniel Espinosa <esodan gmail com>
Date: Fri Nov 29 23:16:31 2019 -0600
GdaParser: remove spaces and enters before next statement
Batch parsing, should remove spacesa and enters before
return next statement.
Fix issue #203
libgda/sql-parser/gda-sql-parser.c | 3 +++
tests/parser/testdata.xml | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/libgda/sql-parser/gda-sql-parser.c b/libgda/sql-parser/gda-sql-parser.c
index 37af1fa65..fa2faa222 100644
--- a/libgda/sql-parser/gda-sql-parser.c
+++ b/libgda/sql-parser/gda-sql-parser.c
@@ -619,6 +619,9 @@ gda_sql_parser_parse_string (GdaSqlParser *parser, const gchar *sql, const gchar
if (* parser->priv->context->next_token_start) {
gint i = parser->priv->context->next_token_start - parser->priv->sql;
*remain = sql + i;
+ while (**remain == ' ' || **remain == '\n') {
+ *remain = sql + (++i);
+ }
}
}
diff --git a/tests/parser/testdata.xml b/tests/parser/testdata.xml
index 82467c697..b10665843 100644
--- a/tests/parser/testdata.xml
+++ b/tests/parser/testdata.xml
@@ -150,7 +150,7 @@
<test id="25">
<sql>aa bb; ; c</sql>
- <expected>{"statements":[{"statement":{"sql":"aa
bb;","stmt_type":"UNKNOWN","contents":[{"value":"aa"},{"value":" "},{"value":"bb"}]}},{"statement":{"sql":"
c","stmt_type":"UNKNOWN","contents":[{"value":" "},{"value":"c"}]}}]}</expected>
+ <expected>{"statements":[{"statement":{"sql":"aa
bb;","stmt_type":"UNKNOWN","contents":[{"value":"aa"},{"value":"
"},{"value":"bb"}]}},{"statement":{"sql":"c","stmt_type":"UNKNOWN","contents":[{"value":"c"}]}}]}</expected>
</test>
<test id="26">
@@ -1048,4 +1048,15 @@
<sql>UPDATE coupons SET limit = 1 WHERE coupons.id = 1</sql>
<expected>{"statements":[{"statement":{"sql":"UPDATE coupons SET limit = 1 WHERE coupons.id =
1","stmt_type":"UPDATE","contents":{"table":"coupons","fields":["limit"],"expressions":[{"value":"1"}],"condition":{"operation":{"operator":"=","operand0":{"value":"coupons.id"},"operand1":{"value":"1"}}}}}}]}</expected>
</test>
+
+ <test id="issue#203">
+ <sql>SELECT * FROM test; SELECT * FROM test2;</sql>
+ <expected>{"statements":[{"statement":{"sql":"SELECT * FROM
test;","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"*"}}],"from":{"targets":[{"expr":{"value":"test"},"table_name":"test"}]}}}},{"statement":{"sql":"SELECT
* FROM
test2;","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"*"}}],"from":{"targets":[{"expr":{"value":"test2"},"table_name":"test2"}]}}}}]}</expected>
+ </test>
+
+ <test id="issue#203-2">
+ <sql>SELECT * FROM test;
+SELECT * FROM test2;</sql>
+ <expected>{"statements":[{"statement":{"sql":"SELECT * FROM
test;","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"*"}}],"from":{"targets":[{"expr":{"value":"test"},"table_name":"test"}]}}}},{"statement":{"sql":"SELECT
* FROM
test2;","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"*"}}],"from":{"targets":[{"expr":{"value":"test2"},"table_name":"test2"}]}}}}]}</expected>
+ </test>
</testdata>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]