-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new(project) add update functionality
- Loading branch information
1 parent
83ac1c2
commit 6bd0413
Showing
9 changed files
with
97 additions
and
8 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
27 changes: 27 additions & 0 deletions
27
noio_db/core/sql_object_factories/update_sql_object_factory.py
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,27 @@ | ||
from noio_db.core.sql_object_factories import AbstractSQLObjectFactory | ||
from noio_db.core.sql_objects import BaseSQLObject, SetSQLObject, UpdateSQLObject | ||
from noio_db.utils import list_into_comma_sql_object | ||
|
||
|
||
class UpdateSQLObjectFactory(AbstractSQLObjectFactory): | ||
def get_object(self, *args) -> BaseSQLObject: | ||
|
||
if len(args) > 1: | ||
raise Exception( | ||
f"Update query must accept only 1 parameter, got {len(args)}" | ||
) | ||
|
||
name = args[0] | ||
|
||
return UpdateSQLObject(name) | ||
|
||
|
||
class SetSQLObjectFactory(AbstractSQLObjectFactory): | ||
def get_object(self, *args) -> BaseSQLObject: | ||
|
||
if len(args) < 1: | ||
raise Exception("Set query must accept at least one parameter, got 0") | ||
|
||
params = list_into_comma_sql_object(*args) | ||
|
||
return SetSQLObject(params) |
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,15 @@ | ||
from string import Template | ||
|
||
from noio_db.core.sql_objects import BaseSQLObject | ||
|
||
|
||
class UpdateSQLObject(BaseSQLObject): | ||
|
||
template = Template("UPDATE $what") | ||
template_keys = ["what"] | ||
|
||
|
||
class SetSQLObject(BaseSQLObject): | ||
|
||
template = Template("SET $what") | ||
template_keys = ["what"] |
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