Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
256a78c9
Commit
256a78c9
authored
2 years ago
by
Дмитрий Кольцов
Browse files
Options
Downloads
Patches
Plain Diff
fix(pest grammar): add cyrillic characters as valid for string values
Closes
#183
parent
c0ca3420
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1414
sbroad import
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/frontend/sql/ir/tests.rs
+36
-0
36 additions, 0 deletions
src/frontend/sql/ir/tests.rs
src/frontend/sql/query.pest
+1
-1
1 addition, 1 deletion
src/frontend/sql/query.pest
test_app/test/integration/api_test.lua
+58
-0
58 additions, 0 deletions
test_app/test/integration/api_test.lua
with
95 additions
and
1 deletion
src/frontend/sql/ir/tests.rs
+
36
−
0
View file @
256a78c9
...
...
@@ -349,6 +349,24 @@ fn front_sql15() {
);
}
// check cyrillic strings support
#[test]
fn
front_sql16
()
{
let
input
=
r#"SELECT "identification_number", "product_code" FROM "hash_testing"
WHERE "product_code" = 'кириллица'"#
;
let
expected
=
PatternWithParams
::
new
(
format!
(
"{} {} {}"
,
r#"SELECT "hash_testing"."identification_number" as "identification_number","#
,
r#""hash_testing"."product_code" as "product_code""#
,
r#"FROM "hash_testing" WHERE ("hash_testing"."product_code") = (?)"#
,
),
vec!
[
Value
::
from
(
"кириллица"
)],
);
assert_eq!
(
sql_to_sql
(
input
,
&
[],
&
no_transform
),
expected
);
}
#[test]
fn
front_params1
()
{
let
pattern
=
r#"SELECT "id", "FIRST_NAME" FROM "test_space"
...
...
@@ -382,3 +400,21 @@ fn front_params2() {
assert_eq!
(
sql_to_sql
(
pattern
,
&
params
,
&
no_transform
),
expected
);
}
// check cyrillic params support
#[test]
fn
front_params3
()
{
let
pattern
=
r#"SELECT "id" FROM "test_space"
WHERE "sys_op" = ? AND "FIRST_NAME" = ?"#
;
let
params
=
vec!
[
Value
::
Null
,
Value
::
from
(
"кириллица"
)];
let
expected
=
PatternWithParams
::
new
(
format!
(
"{} {}"
,
r#"SELECT "test_space"."id" as "id" FROM "test_space""#
,
r#"WHERE ("test_space"."sys_op") = (?) and ("test_space"."FIRST_NAME") = (?)"#
,
),
params
.clone
(),
);
assert_eq!
(
sql_to_sql
(
pattern
,
&
params
,
&
no_transform
),
expected
);
}
This diff is collapsed.
Click to expand it.
src/frontend/sql/query.pest
+
1
−
1
View file @
256a78c9
...
...
@@ -59,7 +59,7 @@ Expr = _{ Or | And | Cmp | Primary | Parentheses }
OrLeft = _{ AndRight }
OrRight = _{ Or | OrLeft }
String = @{ !(WHITESPACE* ~ Keyword ~ WHITESPACE) ~ ('A' .. 'Z' | 'a'..'z' | "-" | "_" | ASCII_DIGIT)+ }
String = @{ !(WHITESPACE* ~ Keyword ~ WHITESPACE) ~ (
'А' .. 'Я' | 'а' .. 'я' |
'A' .. 'Z' | 'a'..'z' | "-" | "_" | ASCII_DIGIT)+ }
Keyword = { ^"union" | ^"where" }
Value = _{ Parameter | Row | True | False | Null | Decimal | Double | Unsigned | Integer | SingleQuotedString }
...
...
This diff is collapsed.
Click to expand it.
test_app/test/integration/api_test.lua
+
58
−
0
View file @
256a78c9
...
...
@@ -440,6 +440,64 @@ g.test_insert_3 = function()
})
end
-- check cyrillic consts support
g
.
test_insert_4
=
function
()
local
api
=
cluster
:
server
(
"api-1"
).
net_box
local
r
,
err
=
api
:
call
(
"query"
,
{
[[INSERT INTO "space_simple_shard_key"
("sysOp", "id", "name") VALUES (?, ?, 'кириллица'), (?, ?, 'КИРИЛЛИЦА')]]
,
{
5
,
4
,
6
,
5
}
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_equals
(
r
,
{
row_count
=
2
})
r
,
err
=
api
:
call
(
"query"
,
{
[[SELECT *, "bucket_id" FROM "space_simple_shard_key"]]
,
{}
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_equals
(
r
,
{
metadata
=
{
{
name
=
"id"
,
type
=
"integer"
},
{
name
=
"name"
,
type
=
"string"
},
{
name
=
"sysOp"
,
type
=
"integer"
},
{
name
=
"bucket_id"
,
type
=
"unsigned"
},
},
rows
=
{
{
1
,
"ok"
,
1
,
3940
},
{
5
,
"КИРИЛЛИЦА"
,
6
,
6661
},
{
10
,
box
.
NULL
,
0
,
11520
},
{
4
,
"кириллица"
,
5
,
27225
},
},
})
end
-- check cyrillic params support
g
.
test_insert_5
=
function
()
local
api
=
cluster
:
server
(
"api-1"
).
net_box
local
r
,
err
=
api
:
call
(
"query"
,
{
[[INSERT INTO "space_simple_shard_key"
("sysOp", "id", "name") VALUES (?, ?, ?), (?, ?, ?)]]
,
{
5
,
4
,
"кириллица"
,
6
,
5
,
"КИРИЛЛИЦА"
}
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_equals
(
r
,
{
row_count
=
2
})
r
,
err
=
api
:
call
(
"query"
,
{
[[SELECT *, "bucket_id" FROM "space_simple_shard_key"]]
,
{}
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_equals
(
r
,
{
metadata
=
{
{
name
=
"id"
,
type
=
"integer"
},
{
name
=
"name"
,
type
=
"string"
},
{
name
=
"sysOp"
,
type
=
"integer"
},
{
name
=
"bucket_id"
,
type
=
"unsigned"
},
},
rows
=
{
{
1
,
"ok"
,
1
,
3940
},
{
5
,
"КИРИЛЛИЦА"
,
6
,
6661
},
{
10
,
box
.
NULL
,
0
,
11520
},
{
4
,
"кириллица"
,
5
,
27225
},
},
})
end
g
.
test_invalid_explain
=
function
()
local
api
=
cluster
:
server
(
"api-1"
).
net_box
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment