@@ -82,63 +82,63 @@ if (current.dialect.supports.JSON) {
8282 it ( 'condition object' , ( ) => {
8383 expectsql ( sql . whereItemQuery ( undefined , Sequelize . json ( { id : 1 } ) ) , {
8484 postgres : '("id"#>>\'{}\') = \'1\'' ,
85- sqlite : "json_extract(`id`, '$') = '1'" ,
86- mariadb : "json_unquote(json_extract(`id`,'$. ')) = '1'" ,
87- mysql : "`id`->>'$.' = '1'"
85+ sqlite : "json_extract(`id`,'$') = '1'" ,
86+ mariadb : "json_unquote(json_extract(`id`,'$')) = '1'" ,
87+ mysql : "json_unquote(json_extract( `id`,'$')) = '1'"
8888 } ) ;
8989 } ) ;
9090
9191 it ( 'nested condition object' , ( ) => {
9292 expectsql ( sql . whereItemQuery ( undefined , Sequelize . json ( { profile : { id : 1 } } ) ) , {
9393 postgres : '("profile"#>>\'{id}\') = \'1\'' ,
94- sqlite : "json_extract(`profile`, '$.id') = '1'" ,
94+ sqlite : "json_extract(`profile`,'$.id') = '1'" ,
9595 mariadb : "json_unquote(json_extract(`profile`,'$.id')) = '1'" ,
96- mysql : "`profile`->> '$.id' = '1'"
96+ mysql : "json_unquote(json_extract( `profile`, '$.\\\"id\\\"')) = '1'"
9797 } ) ;
9898 } ) ;
9999
100100 it ( 'multiple condition object' , ( ) => {
101101 expectsql ( sql . whereItemQuery ( undefined , Sequelize . json ( { property : { value : 1 } , another : { value : 'string' } } ) ) , {
102102 postgres : '("property"#>>\'{value}\') = \'1\' AND ("another"#>>\'{value}\') = \'string\'' ,
103- sqlite : "json_extract(`property`, '$.value') = '1' AND json_extract(`another`, '$.value') = 'string'" ,
104- mariadb : "json_unquote(json_extract(`property`,'$.value')) = '1' and json_unquote(json_extract(`another`,'$.value')) = 'string'" ,
105- mysql : "`property`->> '$.value' = '1' and `another`->> '$.value' = 'string'"
103+ sqlite : "json_extract(`property`,'$.value') = '1' AND json_extract(`another`,'$.value') = 'string'" ,
104+ mariadb : "json_unquote(json_extract(`property`,'$.value')) = '1' AND json_unquote(json_extract(`another`,'$.value')) = 'string'" ,
105+ mysql : "json_unquote(json_extract( `property`, '$.\\\" value\\\"')) = '1' AND json_unquote(json_extract( `another`, '$.\\\" value\\\"')) = 'string'"
106106 } ) ;
107107 } ) ;
108108
109109 it ( 'property array object' , ( ) => {
110110 expectsql ( sql . whereItemQuery ( undefined , Sequelize . json ( { property : [ [ 4 , 6 ] , [ 8 ] ] } ) ) , {
111111 postgres : '("property"#>>\'{0,0}\') = \'4\' AND ("property"#>>\'{0,1}\') = \'6\' AND ("property"#>>\'{1,0}\') = \'8\'' ,
112- sqlite : "json_extract(`property`, '$[0][0]') = '4' AND json_extract(`property`, '$[0][1]') = '6' AND json_extract(`property`, '$[1][0]') = '8'" ,
113- mariadb : "json_unquote(json_extract(`property`,'$.0.0 ')) = '4' and json_unquote(json_extract(`property`,'$.0.1 ')) = '6' and json_unquote(json_extract(`property`,'$.1.0 ')) = '8'" ,
114- mysql : "`property`->>'$.0.0' = '4' and `property`->>'$.0.1' = '6' and `property`->>'$.1.0' = '8'"
112+ sqlite : "json_extract(`property`,'$[0][0]') = '4' AND json_extract(`property`,'$[0][1]') = '6' AND json_extract(`property`,'$[1][0]') = '8'" ,
113+ mariadb : "json_unquote(json_extract(`property`,'$[0][0] ')) = '4' AND json_unquote(json_extract(`property`,'$[0][1] ')) = '6' AND json_unquote(json_extract(`property`,'$[1][0] ')) = '8'" ,
114+ mysql : "json_unquote(json_extract( `property`,'$[0][0]')) = '4' AND json_unquote(json_extract( `property`,'$[0][1]')) = '6' AND json_unquote(json_extract( `property`,'$[1][0]')) = '8'"
115115 } ) ;
116116 } ) ;
117117
118118 it ( 'dot notation' , ( ) => {
119119 expectsql ( sql . whereItemQuery ( Sequelize . json ( 'profile.id' ) , '1' ) , {
120120 postgres : '("profile"#>>\'{id}\') = \'1\'' ,
121- sqlite : "json_extract(`profile`, '$.id') = '1'" ,
121+ sqlite : "json_extract(`profile`,'$.id') = '1'" ,
122122 mariadb : "json_unquote(json_extract(`profile`,'$.id')) = '1'" ,
123- mysql : "`profile`->> '$.id' = '1'"
123+ mysql : "json_unquote(json_extract( `profile`, '$.\\\"id\\\"')) = '1'"
124124 } ) ;
125125 } ) ;
126126
127127 it ( 'item dot notation array' , ( ) => {
128128 expectsql ( sql . whereItemQuery ( Sequelize . json ( 'profile.id.0.1' ) , '1' ) , {
129129 postgres : '("profile"#>>\'{id,0,1}\') = \'1\'' ,
130- sqlite : "json_extract(`profile`, '$.id[0][1]') = '1'" ,
130+ sqlite : "json_extract(`profile`,'$.id[0][1]') = '1'" ,
131131 mariadb : "json_unquote(json_extract(`profile`,'$.id[0][1]')) = '1'" ,
132- mysql : "`profile`->> '$.id [0][1]' = '1'"
132+ mysql : "json_unquote(json_extract( `profile`, '$.\\\"id\\\" [0][1]')) = '1'"
133133 } ) ;
134134 } ) ;
135135
136136 it ( 'column named "json"' , ( ) => {
137137 expectsql ( sql . whereItemQuery ( Sequelize . json ( 'json' ) , '{}' ) , {
138138 postgres : '("json"#>>\'{}\') = \'{}\'' ,
139- sqlite : "json_extract(`json`, '$') = '{}'" ,
140- mariadb : "json_unquote(json_extract(`json`,'$. ')) = '{}'" ,
141- mysql : "`json`->>'$.' = '{}'"
139+ sqlite : "json_extract(`json`,'$') = '{}'" ,
140+ mariadb : "json_unquote(json_extract(`json`,'$')) = '{}'" ,
141+ mysql : "json_unquote(json_extract( `json`,'$')) = '{}'"
142142 } ) ;
143143 } ) ;
144144 } ) ;
0 commit comments