@@ -120,6 +120,88 @@ 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+ // Regression test for https://github.com/dolthub/dolt/issues/9641
125+ Name : "bit union max1err dolt#9641" ,
126+ SetUpScript : []string {
127+ "CREATE TABLE report_card (id INT PRIMARY KEY, archived BIT(1))" ,
128+ "INSERT INTO report_card VALUES (1, 0)" ,
129+ },
130+ Assertions : []ScriptTestAssertion {
131+ {
132+ // max1err
133+ Query : `SELECT archived FROM report_card WHERE id = 1
134+ UNION ALL
135+ SELECT 48 FROM report_card WHERE id = 1` ,
136+ Expected : []sql.Row {{int64 (0 )}, {int64 (48 )}},
137+ },
138+ },
139+ },
140+ {
141+ // Regression test for https://github.com/dolthub/dolt/issues/9641
142+ Name : "bit union comprehensive regression test dolt#9641" ,
143+ Dialect : "mysql" ,
144+ SetUpScript : []string {
145+ `CREATE TABLE t1 (
146+ id int PRIMARY KEY,
147+ name varchar(254),
148+ archived bit(1) NOT NULL DEFAULT b'0',
149+ archived_directly bit(1) NOT NULL DEFAULT b'0'
150+ )` ,
151+ `CREATE TABLE t2 (
152+ id int PRIMARY KEY,
153+ name varchar(254),
154+ archived bit(1) NOT NULL DEFAULT b'0'
155+ )` ,
156+ "INSERT INTO t1 VALUES (1, 'Card1', b'0', b'0')" ,
157+ "INSERT INTO t2 VALUES (2, 'Collection1', b'0')" ,
158+ },
159+ Assertions : []ScriptTestAssertion {
160+ {
161+ Query : `SELECT *,
162+ COUNT(*) OVER () AS total_count
163+ FROM (
164+ SELECT
165+ 5 AS model_ranking,
166+ id,
167+ name,
168+ archived,
169+ archived_directly
170+ FROM t1
171+ WHERE archived_directly = FALSE
172+
173+ UNION ALL
174+
175+ SELECT
176+ 7 AS model_ranking,
177+ id,
178+ name,
179+ archived,
180+ NULL AS archived_directly
181+ FROM t2
182+ WHERE archived = FALSE AND id <> 1
183+ ) AS dummy_alias` ,
184+ Expected : []sql.Row {
185+ {int64 (5 ), int64 (1 ), "Card1" , uint64 (0 ), int64 (0 ), int64 (2 )},
186+ {int64 (7 ), int64 (2 ), "Collection1" , uint64 (0 ), nil , int64 (2 )},
187+ },
188+ },
189+ },
190+ },
191+ {
192+ Name : "bits don't work on server" ,
193+ Dialect : "mysql" ,
194+ SetUpScript : []string {
195+ "create table t (b bit(1));" ,
196+ "insert into t values (1)" ,
197+ },
198+ Assertions : []ScriptTestAssertion {
199+ {
200+ Query : "select * from t;" ,
201+ Expected : []sql.Row {{uint64 (1 )}},
202+ },
203+ },
204+ },
123205 {
124206 Name : "outer join finish unmatched right side" ,
125207 SetUpScript : []string {
0 commit comments