Skip to content

Commit d7c5b3f

Browse files
Preserve table column case in population variables.
Github issue #546
1 parent bad8042 commit d7c5b3f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/core.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ def bayesdb_add_variable(bdb, population_id, name, stattype):
212212
"""Adds a variable to the population, with colno from the base table."""
213213
table_name = bayesdb_population_table(bdb, population_id)
214214
colno = bayesdb_table_column_number(bdb, table_name, name)
215+
# Use the original case of the variable in the table.
216+
name_unfolded = bayesdb_table_column_name(bdb, table_name, colno)
217+
assert casefold(name) == casefold(name_unfolded)
215218
bdb.sql_execute('''
216219
INSERT INTO bayesdb_variable
217220
(population_id, name, colno, stattype)
218221
VALUES (?, ?, ?, ?)
219-
''', (population_id, name, colno, stattype))
222+
''', (population_id, name_unfolded, colno, stattype))
220223

221224
def bayesdb_has_variable(bdb, population_id, generator_id, name):
222225
"""True if the population has a given variable.

tests/test_case.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
def test_case():
24-
pytest.xfail(reason='Github issue #546')
2524
with bayeslite.bayesdb_open(':memory:') as bdb:
2625
bdb.sql_execute('create table t(x,Y)')
2726
bdb.sql_execute('insert into t values(1,2)')

0 commit comments

Comments
 (0)