fix case of fields table
This commit is contained in:
parent
996f4c637f
commit
a961013961
@ -1,5 +1,5 @@
|
||||
SELECT DISTINCT name
|
||||
FROM FIELDS
|
||||
FROM fields
|
||||
WHERE ntid IN (
|
||||
SELECT mid
|
||||
FROM notes
|
||||
|
@ -1,6 +1,6 @@
|
||||
SELECT ord,
|
||||
name,
|
||||
config
|
||||
FROM FIELDS
|
||||
FROM fields
|
||||
WHERE ntid = ?
|
||||
ORDER BY ord
|
@ -1,2 +1,2 @@
|
||||
INSERT INTO FIELDS (ntid, ord, name, config)
|
||||
INSERT INTO fields (ntid, ord, name, config)
|
||||
VALUES (?, ?, ?, ?);
|
@ -1,7 +1,7 @@
|
||||
DROP TABLE config;
|
||||
DROP TABLE deck_config;
|
||||
DROP TABLE tags;
|
||||
DROP TABLE FIELDS;
|
||||
DROP TABLE fields;
|
||||
DROP TABLE templates;
|
||||
DROP TABLE notetypes;
|
||||
DROP TABLE decks;
|
||||
|
@ -1,11 +1,11 @@
|
||||
CREATE TABLE FIELDS (
|
||||
CREATE TABLE fields (
|
||||
ntid integer NOT NULL,
|
||||
ord integer NOT NULL,
|
||||
name text NOT NULL COLLATE unicase,
|
||||
config blob NOT NULL,
|
||||
PRIMARY KEY (ntid, ord)
|
||||
) without rowid;
|
||||
CREATE UNIQUE INDEX idx_fields_name_ntid ON FIELDS (name, ntid);
|
||||
CREATE UNIQUE INDEX idx_fields_name_ntid ON fields (name, ntid);
|
||||
CREATE TABLE templates (
|
||||
ntid integer NOT NULL,
|
||||
ord integer NOT NULL,
|
||||
|
@ -16,13 +16,18 @@ function fixFile(relpath: string, newText: string): void {
|
||||
}
|
||||
|
||||
function formatText(text: string): string {
|
||||
const newText: string = sqlFormatter.format(text, {
|
||||
let newText: string = sqlFormatter.format(text, {
|
||||
indent: " ",
|
||||
reservedWordCase: "upper",
|
||||
});
|
||||
// 'type' is treated as a reserved word, but Anki uses it in various sql
|
||||
// tables, so we don't want it uppercased
|
||||
return newText.replace(/\bTYPE\b/g, "type");
|
||||
// downcase some keywords that Anki uses in tables/columns
|
||||
for (const keyword of ["type", "fields"]) {
|
||||
newText = newText.replace(
|
||||
new RegExp(`\\b${keyword.toUpperCase()}\\b`, "g"),
|
||||
keyword
|
||||
);
|
||||
}
|
||||
return newText;
|
||||
}
|
||||
|
||||
let errorFound = false;
|
||||
|
Loading…
Reference in New Issue
Block a user