diff --git a/Orange/data/variable.py b/Orange/data/variable.py index f7b322501de..f00e92a9bdb 100644 --- a/Orange/data/variable.py +++ b/Orange/data/variable.py @@ -160,6 +160,8 @@ def __new__(cls, variable, value=Unknown): :param value: value """ if variable.is_primitive(): + if isinstance(variable, DiscreteVariable) and isinstance(value, str): + value = variable.to_val(value) self = super().__new__(cls, value) self.variable = variable self._value = None diff --git a/Orange/tests/sql/test_sql_table.py b/Orange/tests/sql/test_sql_table.py index 748f7f13beb..4bcb4696905 100644 --- a/Orange/tests/sql/test_sql_table.py +++ b/Orange/tests/sql/test_sql_table.py @@ -209,6 +209,9 @@ def test_query_subset_of_rows(self): def test_getitem_single_value(self): table = SqlTable(self.conn, self.iris, inspect_values=True) self.assertAlmostEqual(table[0, 0], 5.1) + self.assertAlmostEqual(table[0, table.domain[0]], 5.1) + self.assertEqual(table[0, 4], "Iris-setosa") + self.assertEqual(table[0, table.domain[4]], "Iris-setosa") @dbt.run_on(["postgres", "mssql"]) def test_type_hints(self):