@@ -120,6 +120,175 @@ type ScriptTestAssertion struct {
120120// Unlike other engine tests, ScriptTests must be self-contained. No other tables are created outside the definition of
121121// the tests.
122122var ScriptTests = []ScriptTest {
123+ {
124+ // https://github.com/dolthub/dolt/issues/9794
125+ Name : "UPDATE with TRIM function on TEXT column" ,
126+ SetUpScript : []string {
127+ "create table my_table (txt text);" ,
128+ "insert into my_table values('foobar');" ,
129+ },
130+ Assertions : []ScriptTestAssertion {
131+ {
132+ Query : "update my_table set txt = trim(txt);" ,
133+ SkipResultsCheck : true ,
134+ },
135+ {
136+ Query : "select txt from my_table;" ,
137+ Expected : []sql.Row {{"foobar" }},
138+ },
139+ },
140+ },
141+ {
142+ // https://github.com/dolthub/dolt/issues/9794
143+ Name : "String functions with TextStorage (comprehensive test)" ,
144+ Dialect : "mysql" ,
145+ SetUpScript : []string {
146+ "create table test_strings (id int primary key, content text);" ,
147+ "insert into test_strings values (1, ' Hello World '), (2, 'Test String'), (3, 'LOWERCASE'), (4, 'abc123def');" ,
148+ },
149+ Assertions : []ScriptTestAssertion {
150+ {
151+ Query : "select id, trim(content) from test_strings order by id;" ,
152+ Expected : []sql.Row {{1 , "Hello World" }, {2 , "Test String" }, {3 , "LOWERCASE" }, {4 , "abc123def" }},
153+ },
154+ {
155+ Query : "select id, upper(content) from test_strings order by id;" ,
156+ Expected : []sql.Row {{1 , " HELLO WORLD " }, {2 , "TEST STRING" }, {3 , "LOWERCASE" }, {4 , "ABC123DEF" }},
157+ },
158+ {
159+ Query : "select id, lower(content) from test_strings order by id;" ,
160+ Expected : []sql.Row {{1 , " hello world " }, {2 , "test string" }, {3 , "lowercase" }, {4 , "abc123def" }},
161+ },
162+ {
163+ Query : "select id, reverse(content) from test_strings order by id;" ,
164+ Expected : []sql.Row {{1 , " dlroW olleH " }, {2 , "gnirtS tseT" }, {3 , "ESACREWOL" }, {4 , "fed321cba" }},
165+ },
166+ {
167+ Query : "select id, substring(content, 1, 5) from test_strings order by id;" ,
168+ Expected : []sql.Row {{1 , " Hel" }, {2 , "Test " }, {3 , "LOWER" }, {4 , "abc12" }},
169+ },
170+ {
171+ Query : "select id, length(content) from test_strings order by id;" ,
172+ Expected : []sql.Row {{1 , 15 }, {2 , 11 }, {3 , 9 }, {4 , 9 }},
173+ },
174+ {
175+ Query : "select id, left(content, 3) from test_strings order by id;" ,
176+ Expected : []sql.Row {{1 , " H" }, {2 , "Tes" }, {3 , "LOW" }, {4 , "abc" }},
177+ },
178+ {
179+ Query : "select id, right(content, 3) from test_strings order by id;" ,
180+ Expected : []sql.Row {{1 , "d " }, {2 , "ing" }, {3 , "ASE" }, {4 , "def" }},
181+ },
182+ {
183+ Query : "select id, ltrim(content) from test_strings order by id;" ,
184+ Expected : []sql.Row {{1 , "Hello World " }, {2 , "Test String" }, {3 , "LOWERCASE" }, {4 , "abc123def" }},
185+ },
186+ {
187+ Query : "select id, rtrim(content) from test_strings order by id;" ,
188+ Expected : []sql.Row {{1 , " Hello World" }, {2 , "Test String" }, {3 , "LOWERCASE" }, {4 , "abc123def" }},
189+ },
190+ {
191+ Query : "select id, replace(content, 'e', 'X') from test_strings order by id;" ,
192+ Expected : []sql.Row {{1 , " HXllo World " }, {2 , "TXst String" }, {3 , "LOWERCASE" }, {4 , "abc123dXf" }},
193+ },
194+ {
195+ Query : "select id, repeat(substring(content, 1, 2), 2) from test_strings order by id;" ,
196+ Expected : []sql.Row {{1 , " " }, {2 , "TeTe" }, {3 , "LOLO" }, {4 , "abab" }},
197+ },
198+ {
199+ Query : "select id, lpad(content, 12, '*') from test_strings where id = 4;" ,
200+ Expected : []sql.Row {{4 , "***abc123def" }},
201+ },
202+ {
203+ Query : "select id, rpad(content, 12, '*') from test_strings where id = 4;" ,
204+ Expected : []sql.Row {{4 , "abc123def***" }},
205+ },
206+ {
207+ Query : "select id, locate('o', content) from test_strings order by id;" ,
208+ Expected : []sql.Row {{1 , 7 }, {2 , 0 }, {3 , 2 }, {4 , 0 }},
209+ },
210+ {
211+ Query : "select id, position('o' in content) from test_strings order by id;" ,
212+ Expected : []sql.Row {{1 , 7 }, {2 , 0 }, {3 , 2 }, {4 , 0 }},
213+ },
214+ {
215+ Query : "select id, substr(content, 2, 4) from test_strings order by id;" ,
216+ Expected : []sql.Row {{1 , " Hel" }, {2 , "est " }, {3 , "OWER" }, {4 , "bc12" }},
217+ },
218+ {
219+ Query : "select id, mid(content, 3, 3) from test_strings order by id;" ,
220+ Expected : []sql.Row {{1 , "Hel" }, {2 , "st " }, {3 , "WER" }, {4 , "c12" }},
221+ },
222+ {
223+ Query : "select id, char_length(content) from test_strings order by id;" ,
224+ Expected : []sql.Row {{1 , 15 }, {2 , 11 }, {3 , 9 }, {4 , 9 }},
225+ },
226+ {
227+ Query : "select id, character_length(content) from test_strings order by id;" ,
228+ Expected : []sql.Row {{1 , 15 }, {2 , 11 }, {3 , 9 }, {4 , 9 }},
229+ },
230+ {
231+ Query : "select id, octet_length(content) from test_strings order by id;" ,
232+ Expected : []sql.Row {{1 , 15 }, {2 , 11 }, {3 , 9 }, {4 , 9 }},
233+ },
234+ {
235+ Query : "select id, lcase(content) from test_strings order by id;" ,
236+ Expected : []sql.Row {{1 , " hello world " }, {2 , "test string" }, {3 , "lowercase" }, {4 , "abc123def" }},
237+ },
238+ {
239+ Query : "select id, ucase(content) from test_strings order by id;" ,
240+ Expected : []sql.Row {{1 , " HELLO WORLD " }, {2 , "TEST STRING" }, {3 , "LOWERCASE" }, {4 , "ABC123DEF" }},
241+ },
242+ {
243+ Query : "select id, ascii(content) from test_strings order by id;" ,
244+ Expected : []sql.Row {{1 , uint64 (32 )}, {2 , uint64 (84 )}, {3 , uint64 (76 )}, {4 , uint64 (97 )}},
245+ },
246+ {
247+ Query : "select id, hex(content) from test_strings where id = 4;" ,
248+ Expected : []sql.Row {{4 , "616263313233646566" }},
249+ },
250+ {
251+ Query : "select id, unhex(hex(content)) = content from test_strings where id = 4;" ,
252+ Expected : []sql.Row {{4 , true }},
253+ },
254+ {
255+ Query : "select id, substring_index(content, 'e', 1) from test_strings order by id;" ,
256+ Expected : []sql.Row {{1 , " H" }, {2 , "T" }, {3 , "LOWERCASE" }, {4 , "abc123d" }},
257+ },
258+ {
259+ Query : "select id, insert(content, 2, 3, 'XYZ') from test_strings where id = 4;" ,
260+ Expected : []sql.Row {{4 , "aXYZ23def" }},
261+ },
262+ {
263+ Query : "update test_strings set content = concat(trim(content), '!');" ,
264+ SkipResultsCheck : true ,
265+ },
266+ {
267+ Query : "select id, content from test_strings order by id;" ,
268+ Expected : []sql.Row {{1 , "Hello World!" }, {2 , "Test String!" }, {3 , "LOWERCASE!" }, {4 , "abc123def!" }},
269+ },
270+ {
271+ Query : "SELECT CONCAT_WS(',', content, 'suffix') FROM test_strings WHERE id = 2;" ,
272+ Expected : []sql.Row {{"Test String!,suffix" }},
273+ },
274+ {
275+ Query : "SELECT EXPORT_SET(5, content, 'off') FROM test_strings WHERE id = 2;" ,
276+ Expected : []sql.Row {{"Test String!,off,Test String!,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off,off" }},
277+ },
278+ {
279+ Query : "SELECT FIND_IN_SET('String', content) FROM test_strings WHERE id = 2;" ,
280+ Expected : []sql.Row {{int32 (0 )}},
281+ },
282+ {
283+ Query : "SELECT MAKE_SET(3, content, 'second', 'third') FROM test_strings WHERE id = 2;" ,
284+ Expected : []sql.Row {{"Test String!,second" }},
285+ },
286+ {
287+ Query : "SELECT SOUNDEX(content) FROM test_strings WHERE id = 2;" ,
288+ Expected : []sql.Row {{"T2323652" }},
289+ },
290+ },
291+ },
123292 {
124293 // Regression test for https://github.com/dolthub/dolt/issues/9641
125294 Name : "bit union max1err dolt#9641" ,
0 commit comments