Fossil SCM

Give the JX column of USER and REPORTFMT a default value which is valid JSON.

drh 2022-11-18 18:33 json-meta-data
Commit 2433964d8f4ac36300c9fc27abe3fe0b87f913c0d29e8a36dbdfec225444ae43
3 files changed +2 -1 +2 -2 +2 -1
+2 -1
--- src/report.c
+++ src/report.c
@@ -263,11 +263,12 @@
263263
** The "jx" column is intended to hold a JSON object containing optional
264264
** key-value pairs.
265265
*/
266266
void report_update_reportfmt_table(void){
267267
if( db_table_has_column("repository","reportfmt","jx")==0 ){
268
- db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT;");
268
+ db_multi_exec("ALTER TABLE repository.reportfmt"
269
+ " ADD COLUMN jx TEXT DEFAULT '{}';");
269270
}
270271
}
271272
272273
/*
273274
** Activate the ticket report query authorizer. Must be followed by an
274275
--- src/report.c
+++ src/report.c
@@ -263,11 +263,12 @@
263 ** The "jx" column is intended to hold a JSON object containing optional
264 ** key-value pairs.
265 */
266 void report_update_reportfmt_table(void){
267 if( db_table_has_column("repository","reportfmt","jx")==0 ){
268 db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT;");
 
269 }
270 }
271
272 /*
273 ** Activate the ticket report query authorizer. Must be followed by an
274
--- src/report.c
+++ src/report.c
@@ -263,11 +263,12 @@
263 ** The "jx" column is intended to hold a JSON object containing optional
264 ** key-value pairs.
265 */
266 void report_update_reportfmt_table(void){
267 if( db_table_has_column("repository","reportfmt","jx")==0 ){
268 db_multi_exec("ALTER TABLE repository.reportfmt"
269 " ADD COLUMN jx TEXT DEFAULT '{}';");
270 }
271 }
272
273 /*
274 ** Activate the ticket report query authorizer. Must be followed by an
275
+2 -2
--- src/schema.c
+++ src/schema.c
@@ -127,11 +127,11 @@
127127
@ ipaddr TEXT, -- IP address for which cookie is valid
128128
@ cexpire DATETIME, -- Time when cookie expires
129129
@ info TEXT, -- contact information
130130
@ mtime DATE, -- last change. seconds since 1970
131131
@ photo BLOB, -- JPEG image of this user
132
-@ jx TEXT -- Extra fields in JSON
132
+@ jx TEXT DEFAULT '{}' -- Extra fields in JSON
133133
@ );
134134
@
135135
@ -- The config table holds miscellanous information about the repository.
136136
@ -- in the form of name-value pairs.
137137
@ --
@@ -178,11 +178,11 @@
178178
@ owner TEXT, -- Owner of this report format (not used)
179179
@ title TEXT UNIQUE, -- Title of this report
180180
@ mtime DATE, -- Last modified. seconds since 1970
181181
@ cols TEXT, -- A color-key specification
182182
@ sqlcode TEXT, -- An SQL SELECT statement for this report
183
-@ jx TEXT -- Additional fields encoded as JSON
183
+@ jx TEXT DEFAULT '{}' -- Additional fields encoded as JSON
184184
@ );
185185
@
186186
@ -- Some ticket content (such as the originators email address or contact
187187
@ -- information) needs to be obscured to protect privacy. This is achieved
188188
@ -- by storing an SHA1 hash of the content. For display, the hash is
189189
--- src/schema.c
+++ src/schema.c
@@ -127,11 +127,11 @@
127 @ ipaddr TEXT, -- IP address for which cookie is valid
128 @ cexpire DATETIME, -- Time when cookie expires
129 @ info TEXT, -- contact information
130 @ mtime DATE, -- last change. seconds since 1970
131 @ photo BLOB, -- JPEG image of this user
132 @ jx TEXT -- Extra fields in JSON
133 @ );
134 @
135 @ -- The config table holds miscellanous information about the repository.
136 @ -- in the form of name-value pairs.
137 @ --
@@ -178,11 +178,11 @@
178 @ owner TEXT, -- Owner of this report format (not used)
179 @ title TEXT UNIQUE, -- Title of this report
180 @ mtime DATE, -- Last modified. seconds since 1970
181 @ cols TEXT, -- A color-key specification
182 @ sqlcode TEXT, -- An SQL SELECT statement for this report
183 @ jx TEXT -- Additional fields encoded as JSON
184 @ );
185 @
186 @ -- Some ticket content (such as the originators email address or contact
187 @ -- information) needs to be obscured to protect privacy. This is achieved
188 @ -- by storing an SHA1 hash of the content. For display, the hash is
189
--- src/schema.c
+++ src/schema.c
@@ -127,11 +127,11 @@
127 @ ipaddr TEXT, -- IP address for which cookie is valid
128 @ cexpire DATETIME, -- Time when cookie expires
129 @ info TEXT, -- contact information
130 @ mtime DATE, -- last change. seconds since 1970
131 @ photo BLOB, -- JPEG image of this user
132 @ jx TEXT DEFAULT '{}' -- Extra fields in JSON
133 @ );
134 @
135 @ -- The config table holds miscellanous information about the repository.
136 @ -- in the form of name-value pairs.
137 @ --
@@ -178,11 +178,11 @@
178 @ owner TEXT, -- Owner of this report format (not used)
179 @ title TEXT UNIQUE, -- Title of this report
180 @ mtime DATE, -- Last modified. seconds since 1970
181 @ cols TEXT, -- A color-key specification
182 @ sqlcode TEXT, -- An SQL SELECT statement for this report
183 @ jx TEXT DEFAULT '{}' -- Additional fields encoded as JSON
184 @ );
185 @
186 @ -- Some ticket content (such as the originators email address or contact
187 @ -- information) needs to be obscured to protect privacy. This is achieved
188 @ -- by storing an SHA1 hash of the content. For display, the hash is
189
+2 -1
--- src/user.c
+++ src/user.c
@@ -583,11 +583,12 @@
583583
** The "JX" column is intended to hold a JSON object containing optional
584584
** key-value pairs.
585585
*/
586586
void user_update_user_table(void){
587587
if( db_table_has_column("repository","user","jx")==0 ){
588
- db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT;");
588
+ db_multi_exec("ALTER TABLE repository.user"
589
+ " ADD COLUMN jx TEXT DEFAULT '{}';");
589590
}
590591
}
591592
592593
/*
593594
** COMMAND: test-hash-passwords
594595
--- src/user.c
+++ src/user.c
@@ -583,11 +583,12 @@
583 ** The "JX" column is intended to hold a JSON object containing optional
584 ** key-value pairs.
585 */
586 void user_update_user_table(void){
587 if( db_table_has_column("repository","user","jx")==0 ){
588 db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT;");
 
589 }
590 }
591
592 /*
593 ** COMMAND: test-hash-passwords
594
--- src/user.c
+++ src/user.c
@@ -583,11 +583,12 @@
583 ** The "JX" column is intended to hold a JSON object containing optional
584 ** key-value pairs.
585 */
586 void user_update_user_table(void){
587 if( db_table_has_column("repository","user","jx")==0 ){
588 db_multi_exec("ALTER TABLE repository.user"
589 " ADD COLUMN jx TEXT DEFAULT '{}';");
590 }
591 }
592
593 /*
594 ** COMMAND: test-hash-passwords
595

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button