Skip to content

Commit

Permalink
added templates for each query
Browse files Browse the repository at this point in the history
  • Loading branch information
vahagz committed Feb 6, 2024
1 parent 8457e2b commit 59ba56d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions services/parser/query/ddl/create/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import (
"go-dbms/services/parser/query/ddl/create/types"
)

/*
CREATE TABLE <tableName> (
<columnName> <type> [AUTO INCREMENT],
...
)
PRIMARY KEY (<...columns>) <primaryKeyName>
[, INDEX(<...columns>) <indexName>]
...;
*/
type QueryCreateTable struct {
*QueryCreate
Database string `json:"database"`
Expand Down
5 changes: 5 additions & 0 deletions services/parser/query/dml/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"go-dbms/services/parser/query"
)

/*
DELETE FROM <tableName>
[WHERE_INDEX <indexName> <condition> [AND <condition>]]
[WHERE <...condition>];
*/
type QueryDelete struct {
query.Query
DB string `json:"db"`
Expand Down
7 changes: 7 additions & 0 deletions services/parser/query/dml/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"go-dbms/services/parser/query"
)

/*
INSERT INTO <tableName> (...columns)
VALUES
(...values)
...
(...values);
*/
type QueryInsert struct {
query.Query
DB string `json:"db"`
Expand Down
3 changes: 3 additions & 0 deletions services/parser/query/dml/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"go-dbms/services/parser/query"
)

/*
PREPARE TABLE <tableName> ROWS <n>;
*/
type QueryPrepare struct {
query.Query
DB string
Expand Down
6 changes: 6 additions & 0 deletions services/parser/query/dml/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (
"go-dbms/services/parser/query"
)

/*
SELECT <...columns>
FROM <tableName>
[WHERE_INDEX <indexName> <condition> [AND <condition>]]
[WHERE <...condition>];
*/
type QuerySelect struct {
query.Query
Columns []string `json:"columns"`
Expand Down
9 changes: 9 additions & 0 deletions services/parser/query/dml/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import (
"go-dbms/services/parser/query"
)

/*
UPDATE <tableName>
SET
<columnName> = <value>,
...
<columnName> = <value>
[WHERE_INDEX <indexName> <condition> [AND <condition>]]
[WHERE <...condition>];
*/
type QueryUpdate struct {
query.Query
DB string `json:"db"`
Expand Down

0 comments on commit 59ba56d

Please sign in to comment.