Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sbroad
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
sbroad
Compare revisions
6dcdab76d3f04181928a0a211867c3a2fa3387ed to 7c708e6322301c43a7e4fb0fff262e8afd3f90a6
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
core/sbroad
Select target project
No results found
7c708e6322301c43a7e4fb0fff262e8afd3f90a6
Select Git revision
Swap
Target
core/sbroad
Select target project
core/sbroad
1 result
6dcdab76d3f04181928a0a211867c3a2fa3387ed
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
fix: drop plugin parsing
· 7c708e63
Denis Smirnov
authored
6 months ago
7c708e63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sbroad-core/src/frontend/sql.rs
+44
-26
44 additions, 26 deletions
sbroad-core/src/frontend/sql.rs
sbroad-core/src/ir/node/plugin.rs
+11
-0
11 additions, 0 deletions
sbroad-core/src/ir/node/plugin.rs
with
55 additions
and
26 deletions
sbroad-core/src/frontend/sql.rs
View file @
7c708e63
...
...
@@ -2883,37 +2883,55 @@ fn parse_drop_plugin(
node
:
&
ParseNode
,
)
->
Result
<
DropPlugin
,
SbroadError
>
{
let
mut
if_exists
=
false
;
let
first_node_idx
=
node
.first_child
();
let
plugin_name_child_idx
=
if
let
Rule
::
IfExists
=
ast
.nodes
.get_node
(
first_node_idx
)
?
.rule
{
if_exists
=
true
;
1
}
else
{
0
};
let
plugin_name_idx
=
node
.child_n
(
plugin_name_child_idx
);
let
name
=
parse_identifier
(
ast
,
plugin_name_idx
)
?
;
let
version_idx
=
node
.child_n
(
plugin_name_child_idx
+
1
);
let
version
=
parse_identifier
(
ast
,
version_idx
)
?
;
let
mut
with_data
=
false
;
let
next_node_idx
=
node
.child_n
(
plugin_name_child_idx
+
2
);
let
next_child_n
=
if
let
Rule
::
WithData
=
ast
.nodes
.get_node
(
next_node_idx
)
?
.rule
{
with_data
=
true
;
plugin_name_child_idx
+
3
}
else
{
plugin_name_child_idx
+
2
};
let
mut
name
=
None
;
let
mut
version
=
None
;
let
mut
timeout
=
plugin
::
get_default_timeout
();
if
let
Some
(
timeout_child_id
)
=
node
.children
.get
(
next_child_n
)
{
timeout
=
get_timeout
(
ast
,
*
timeout_child_id
)
?
;
for
child_id
in
&
node
.children
{
let
child
=
ast
.nodes
.get_node
(
*
child_id
)
?
;
match
child
.rule
{
Rule
::
IfExists
=>
if_exists
=
true
,
Rule
::
WithData
=>
with_data
=
true
,
Rule
::
Identifier
=>
{
if
name
.is_none
()
{
name
=
Some
(
parse_identifier
(
ast
,
*
child_id
)
?
);
continue
;
}
return
Err
(
SbroadError
::
Invalid
(
Entity
::
AST
,
Some
(
"Plugin name is already set."
.into
()),
));
}
Rule
::
PluginVersion
=>
{
if
version
.is_none
()
{
version
=
Some
(
parse_identifier
(
ast
,
*
child_id
)
?
);
continue
;
}
return
Err
(
SbroadError
::
Invalid
(
Entity
::
AST
,
Some
(
"Plugin version is already set."
.into
()),
));
}
Rule
::
Timeout
=>
timeout
=
get_timeout
(
ast
,
*
child_id
)
?
,
_
=>
{
return
Err
(
SbroadError
::
Invalid
(
Entity
::
AST
,
Some
(
format_smolstr!
(
"Unexpected AST node in DROP PLUGIN: {:?}"
,
child
.rule
)),
))
}
}
}
Ok
(
DropPlugin
{
name
,
version
,
name
:
name
.ok_or_else
(||
{
SbroadError
::
Invalid
(
Entity
::
AST
,
Some
(
"Plugin name is not set."
.into
()))
})
?
,
version
:
version
.ok_or_else
(||
{
SbroadError
::
Invalid
(
Entity
::
AST
,
Some
(
"Plugin version is not set."
.into
()))
})
?
,
if_exists
,
with_data
,
timeout
,
...
...
This diff is collapsed.
Click to expand it.
sbroad-core/src/ir/node/plugin.rs
View file @
7c708e63
...
...
@@ -349,6 +349,17 @@ mod test {
timeout
:
Decimal
::
from
(
1
),
}),
},
TestCase
{
sql
:
r#"DROP PLUGIN "abc" 1.1.1"#
,
arena_type
:
ArenaType
::
Arena96
,
expected
:
PluginOwned
::
Drop
(
DropPlugin
{
name
:
SmolStr
::
from
(
"abc"
),
version
:
SmolStr
::
from
(
"1.1.1"
),
if_exists
:
false
,
with_data
:
false
,
timeout
:
Decimal
::
from
(
10
),
}),
},
TestCase
{
sql
:
r#"DROP PLUGIN "abc" 1.1.1 option(timeout=1)"#
,
arena_type
:
ArenaType
::
Arena96
,
...
...
This diff is collapsed.
Click to expand it.