@@ -63,18 +63,15 @@ def __init__(self, client: Client, table: sql.Composable) -> None:
6363 async def one (self , item : T ) -> T :
6464 """Create one new record with a given item."""
6565 columns : List [sql .Identifier ] = []
66- values : List [sql .Identifier ] = []
66+ values : List [sql .Literal ] = []
6767
6868 for column , value in item .items ():
69- if column == '_id' :
70- values .append (sql .Identifier (str (value )))
71- else :
72- values .append (sql .Identifier (value ))
69+ values .append (sql .Literal (value ))
7370
7471 columns .append (sql .Identifier (column ))
7572
7673 query = sql .SQL (
77- 'INSERT INTO {table}({columns}) '
74+ 'INSERT INTO {table} ({columns}) '
7875 'VALUES ({values}) '
7976 'RETURNING *;'
8077 ).format (
@@ -103,10 +100,10 @@ async def one_by_id(self, id_value: str) -> T:
103100 query = sql .SQL (
104101 'SELECT * '
105102 'FROM {table} '
106- 'WHERE id = {id_value};'
103+ 'WHERE _id = {id_value};'
107104 ).format (
108105 table = self ._table ,
109- id_value = sql .Identifier (id_value )
106+ id_value = sql .Literal (id_value )
110107 )
111108
112109 result : List [T ] = await self ._client .execute_and_return (query )
@@ -178,7 +175,7 @@ def __init__(self, client: Client, table: sql.Composable) -> None:
178175 self ._client = client
179176 self ._table = table
180177
181- async def one (self , id_value : str ) -> T :
178+ async def one_by_id (self , id_value : str ) -> T :
182179 """Delete one record with matching ID."""
183180 query = sql .SQL (
184181 'DELETE FROM {table} '
0 commit comments