From 3290d5dc91f4bc232cf981ce44c9bf7ad58af100 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 14 May 2025 17:12:29 +0200 Subject: [PATCH] Consistently use `entryId` name everywhere --- lib/_data_ingestion/jmdict/objects.dart | 6 +++--- lib/_data_ingestion/jmdict/seed_data.dart | 20 ++++++++++---------- lib/_data_ingestion/jmdict/xml_parser.dart | 2 +- migrations/0001_JMDict.sql | 8 ++++---- migrations/0007_TANOS_JLPT_TAGS.sql | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/_data_ingestion/jmdict/objects.dart b/lib/_data_ingestion/jmdict/objects.dart index 74af620..7e88dd4 100644 --- a/lib/_data_ingestion/jmdict/objects.dart +++ b/lib/_data_ingestion/jmdict/objects.dart @@ -211,17 +211,17 @@ class Sense extends SQLWritable { } class Entry extends SQLWritable { - final int id; + final int entryId; final List kanji; final List readings; final List senses; const Entry({ - required this.id, + required this.entryId, required this.kanji, required this.readings, required this.senses, }); - Map get sqlValue => {'id': id}; + Map get sqlValue => {'entryId': entryId}; } diff --git a/lib/_data_ingestion/jmdict/seed_data.dart b/lib/_data_ingestion/jmdict/seed_data.dart index 2474c01..b5e142b 100644 --- a/lib/_data_ingestion/jmdict/seed_data.dart +++ b/lib/_data_ingestion/jmdict/seed_data.dart @@ -77,14 +77,14 @@ Future seedJMDictData(List entries, Database db) async { for (final k in e.kanji) { b.insert( JMdictTableNames.kanjiElement, - k.sqlValue..addAll({'entryId': e.id}), + k.sqlValue..addAll({'entryId': e.entryId}), ); for (final i in k.info) { b.insert( JMdictTableNames.kanjiInfo, { - 'entryId': e.id, + 'entryId': e.entryId, 'reading': k.reading, 'info': i, }, @@ -95,14 +95,14 @@ Future seedJMDictData(List entries, Database db) async { for (final r in e.readings) { b.insert( JMdictTableNames.readingElement, - r.sqlValue..addAll({'entryId': e.id}), + r.sqlValue..addAll({'entryId': e.entryId}), ); for (final i in r.info) { b.insert( JMdictTableNames.readingInfo, { - 'entryId': e.id, + 'entryId': e.entryId, 'reading': r.reading, 'info': i, }, @@ -112,7 +112,7 @@ Future seedJMDictData(List entries, Database db) async { b.insert( JMdictTableNames.readingRestriction, { - 'entryId': e.id, + 'entryId': e.entryId, 'reading': r.reading, 'restriction': res, }, @@ -128,7 +128,7 @@ Future seedJMDictData(List entries, Database db) async { for (final e in entries) { for (final s in e.senses) { - b.insert(JMdictTableNames.sense, s.sqlValue..addAll({'entryId': e.id})); + b.insert(JMdictTableNames.sense, s.sqlValue..addAll({'entryId': e.entryId})); for (final d in s.dialects) { b.insert( JMdictTableNames.senseDialect, @@ -150,13 +150,13 @@ Future seedJMDictData(List entries, Database db) async { for (final rk in s.restrictedToKanji) { b.insert( JMdictTableNames.senseRestrictedToKanji, - {'entryId': e.id, 'senseId': s.id, 'kanji': rk}, + {'entryId': e.entryId, 'senseId': s.id, 'kanji': rk}, ); } for (final rr in s.restrictedToReading) { b.insert( JMdictTableNames.senseRestrictedToReading, - {'entryId': e.id, 'senseId': s.id, 'reading': rr}, + {'entryId': e.entryId, 'senseId': s.id, 'reading': rr}, ); } for (final ls in s.languageSource) { @@ -215,7 +215,7 @@ Future seedJMDictData(List entries, Database db) async { JMdictTableNames.senseSeeAlso, { 'senseId': s.id, - 'xrefEntryId': resolvedEntry.entry.id, + 'xrefEntryId': resolvedEntry.entry.entryId, 'seeAlsoKanji': xref.kanjiRef, 'seeAlsoReading': xref.readingRef, 'seeAlsoSense': xref.senseOrderNum, @@ -233,7 +233,7 @@ Future seedJMDictData(List entries, Database db) async { b.insert(JMdictTableNames.senseAntonyms, { 'senseId': s.id, - 'xrefEntryId': resolvedEntry.entry.id, + 'xrefEntryId': resolvedEntry.entry.entryId, 'antonymKanji': ant.kanjiRef, 'antonymReading': ant.readingRef, 'antonymSense': ant.senseOrderNum, diff --git a/lib/_data_ingestion/jmdict/xml_parser.dart b/lib/_data_ingestion/jmdict/xml_parser.dart index cfe03f1..0ba7875 100644 --- a/lib/_data_ingestion/jmdict/xml_parser.dart +++ b/lib/_data_ingestion/jmdict/xml_parser.dart @@ -190,7 +190,7 @@ List parseJMDictData(XmlElement root) { entries.add( Entry( - id: entryId, + entryId: entryId, kanji: kanjiEls, readings: readingEls, senses: senses, diff --git a/migrations/0001_JMDict.sql b/migrations/0001_JMDict.sql index eab2c6b..3e38fcf 100644 --- a/migrations/0001_JMDict.sql +++ b/migrations/0001_JMDict.sql @@ -33,13 +33,13 @@ CREATE TABLE "JMdict_InfoReading" ( -- not implement a check for it. CREATE TABLE "JMdict_Entry" ( - "id" INTEGER PRIMARY KEY + "entryId" INTEGER PRIMARY KEY ); -- KanjiElement CREATE TABLE "JMdict_KanjiElement" ( - "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("id"), + "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("entryId"), "orderNum" INTEGER NOT NULL, "reading" TEXT NOT NULL, "news" INTEGER CHECK ("news" BETWEEN 1 AND 2), @@ -64,7 +64,7 @@ CREATE TABLE "JMdict_KanjiElementInfo" ( -- ReadingElement CREATE TABLE "JMdict_ReadingElement" ( - "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("id"), + "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("entryId"), "orderNum" INTEGER NOT NULL, "reading" TEXT NOT NULL, "readingDoesNotMatchKanji" BOOLEAN NOT NULL DEFAULT FALSE, @@ -100,7 +100,7 @@ CREATE TABLE "JMdict_ReadingElementInfo" ( CREATE TABLE "JMdict_Sense" ( "id" INTEGER PRIMARY KEY, - "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("id"), + "entryId" INTEGER NOT NULL REFERENCES "JMdict_Entry"("entryId"), "orderNum" INTEGER NOT NULL, UNIQUE("entryId", "orderNum") ); diff --git a/migrations/0007_TANOS_JLPT_TAGS.sql b/migrations/0007_TANOS_JLPT_TAGS.sql index 6275aa2..ebb7a06 100644 --- a/migrations/0007_TANOS_JLPT_TAGS.sql +++ b/migrations/0007_TANOS_JLPT_TAGS.sql @@ -2,7 +2,7 @@ CREATE TABLE "JMdict_JLPTTag" ( "entryId" INTEGER NOT NULL, "jlptLevel" CHAR(2) NOT NULL CHECK ("jlptLevel" in ('N5', 'N4', 'N3', 'N2', 'N1')), FOREIGN KEY ("entryId") - REFERENCES "JMdict_Entry"("id"), + REFERENCES "JMdict_Entry"("entryId"), PRIMARY KEY ("entryId", "jlptLevel") ) WITHOUT ROWID;