-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from stephenafamo/queries
Groundwork for code generation for queries
- Loading branch information
Showing
25 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2339,6 +2339,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "TypeMonstersEnumNullable", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2490,6 +2490,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "TypeMonstersEnumNullable", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4578,6 +4578,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4743,6 +4743,7 @@ | |
"comment": "" | ||
} | ||
], | ||
"query_folders": null, | ||
"enums": [ | ||
{ | ||
"Type": "UnicodeEnum", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package drivers | ||
|
||
type QueryFolder struct { | ||
Path string | ||
Files []QueryFile | ||
} | ||
|
||
type QueryFile struct { | ||
Path string | ||
Queries []Query | ||
} | ||
|
||
type Query struct { | ||
Name string `yaml:"name"` | ||
SQL string `yaml:"raw"` | ||
RowName string `yaml:"row_name"` | ||
GenerateRow bool `yaml:"generate_row"` | ||
|
||
Columns []QueryArg `yaml:"columns"` | ||
Args []QueryArg `yaml:"args"` | ||
} | ||
|
||
type QueryArg struct { | ||
Name string `yaml:"name"` | ||
Nullable bool `yaml:"nullable"` | ||
TypeName string `yaml:"type"` | ||
Refs []Ref `yaml:"refs"` | ||
} | ||
|
||
type Ref struct { | ||
Key string `yaml:"key"` | ||
Column string `yaml:"column"` | ||
} | ||
|
||
type db interface { | ||
GetColumn(key string, col string) Column | ||
} | ||
|
||
func (c QueryArg) Type(db db) string { | ||
if len(c.Refs) == 0 { | ||
return c.TypeName | ||
} | ||
|
||
ref := db.GetColumn(c.Refs[0].Key, c.Refs[0].Column).Type | ||
|
||
for _, r := range c.Refs[1:] { | ||
if ref != db.GetColumn(r.Key, r.Column).Type { | ||
return c.TypeName | ||
} | ||
} | ||
|
||
return ref | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.