-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: clean up shillelagh implementation
initially i was implementing a sql interface within the dto objects, as the solution grew it made more sense to be able to consolidate this into the shillelagh extension, ensuring that if the sql interface isn't in use the normal dto isn't burdened by imports i've kept some helper methods to concat dictionaries of annotations, this should not affect the workings of the solution refs #31
- Loading branch information
Showing
5 changed files
with
80 additions
and
128 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
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 |
---|---|---|
@@ -1,54 +1,2 @@ | ||
|
||
|
||
|
||
@classmethod | ||
def _shillelagh_columns(cls) -> dict: | ||
"""Return the model as a __shillelagh__ compatible attribute config | ||
Rules here are that we translate as many dictionary vars into | ||
a __shillelagh__ compatible format. | ||
If they are hrefs to other children then we select the id field for | ||
each one of those objects | ||
""" | ||
from shillelagh.fields import ( | ||
Field, | ||
Integer, | ||
String, | ||
Boolean, | ||
Blob, | ||
Collection, | ||
Date, | ||
DateTime, | ||
Float, | ||
ISODate, | ||
ISODateTime, | ||
IntBoolean, | ||
StringBlob, | ||
StringBoolean, | ||
StringDate, | ||
StringDateTime, | ||
StringDecimal, | ||
StringDuration, | ||
StringInteger, | ||
StringTime, | ||
) | ||
|
||
_map = { | ||
int: Integer, | ||
str: String, | ||
bool: Boolean, | ||
bytes: Blob, | ||
list: Collection, | ||
datetime: DateTime, | ||
float: Float, | ||
} | ||
|
||
# Make a key, value pair of all the class attributes | ||
# that are have a primitive type | ||
table_fields = { | ||
key: _map[value]() | ||
for key, value in cls.__annotations__.items() # annotations not fields | ||
if not key.startswith("_") and value in _map | ||
} | ||
return table_fields | ||
""" Utilities to help Shillelagh CLI commands | ||
""" |