Skip to content

Commit d1bdfdf

Browse files
committed
Merge branch 'mr/cardao/change-sqlite-table-id-type' into 'master'
Change some Store tables id type See merge request it/e3-core!142
2 parents 53f061d + fdec2ff commit d1bdfdf

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/e3/anod/store/__init__.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __init__(self, db: os.PathLike | None = None) -> None:
236236
)
237237
self.cursor.execute(
238238
f"CREATE TABLE IF NOT EXISTS {_Store.TableName.files}("
239-
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
239+
" id TEXT NOT NULL PRIMARY KEY,"
240240
" name TEXT NOT NULL,"
241241
" alias TEXT NOT NULL,"
242242
" filename TEXT NOT NULL,"
@@ -273,19 +273,19 @@ def __init__(self, db: os.PathLike | None = None) -> None:
273273
)
274274
self.cursor.execute(
275275
f"CREATE TABLE IF NOT EXISTS {_Store.TableName.components}("
276-
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
277-
" name TEXT NOT NULL,"
278-
" platform TEXT NOT NULL,"
279-
" version TEXT NOT NULL,"
280-
" specname TEXT," # Can be Null
281-
" build_id TEXT NOT NULL,"
282-
" creation_date TEXT NOT NULL DEFAULT("
283-
" STRFTIME('%Y-%m-%d %H:%M:%f+00:00', 'now')"
284-
" ),"
285-
" is_valid INTEGER NOT NULL DEFAULT 1 CHECK(is_valid in (0, 1)),"
286-
" is_published INTEGER NOT NULL DEFAULT 0 CHECK(is_published in (0, 1)),"
276+
" id TEXT NOT NULL PRIMARY KEY,"
277+
" name TEXT NOT NULL,"
278+
" platform TEXT NOT NULL,"
279+
" version TEXT NOT NULL,"
280+
" specname TEXT," # Can be Null
281+
" build_id TEXT NOT NULL,"
282+
" creation_date TEXT NOT NULL DEFAULT("
283+
" STRFTIME('%Y-%m-%d %H:%M:%f+00:00', 'now')"
284+
" ),"
285+
" is_valid INTEGER NOT NULL DEFAULT 1 CHECK(is_valid in (0, 1)),"
286+
" is_published INTEGER NOT NULL DEFAULT 0 CHECK(is_published in (0, 1)),"
287287
# Component has at least one file
288-
" readme_id TEXT"
288+
" readme_id TEXT"
289289
")"
290290
)
291291
self.connection.commit()
@@ -682,7 +682,7 @@ def _tuple_to_comp(
682682
releases = [ # type: ignore[misc]
683683
name
684684
for _, name, _ in self._select(
685-
_Store.TableName.component_releases, ["id"], [comp_id] # type: ignore[arg-type]
685+
_Store.TableName.component_releases, ["component_id"], [comp_id] # type: ignore[arg-type]
686686
)
687687
]
688688

@@ -890,6 +890,7 @@ def insert_to_component_files(
890890
req_tuple = self._insert(
891891
_Store.TableName.components,
892892
[ # type: ignore[arg-type]
893+
"id",
893894
"name",
894895
"platform",
895896
"version",
@@ -900,6 +901,7 @@ def insert_to_component_files(
900901
"readme_id",
901902
],
902903
[
904+
str(ObjectId()),
903905
component_info["name"],
904906
component_info["platform"],
905907
component_info["version"],
@@ -1066,6 +1068,7 @@ def _submit_file(self, file_info: FileDict) -> FileDict:
10661068
req_tuple = self._insert(
10671069
_Store.TableName.files,
10681070
[ # type: ignore[arg-type]
1071+
"id",
10691072
"name",
10701073
"alias",
10711074
"filename",
@@ -1076,6 +1079,7 @@ def _submit_file(self, file_info: FileDict) -> FileDict:
10761079
"metadata",
10771080
],
10781081
[
1082+
str(ObjectId()),
10791083
file_info["name"],
10801084
file_info["alias"],
10811085
file_info["filename"],

0 commit comments

Comments
 (0)