Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type f not supported when selected data with column of type float #76

Open
kinvaris opened this issue Sep 9, 2024 · 1 comment
Open

Comments

@kinvaris
Copy link

kinvaris commented Sep 9, 2024

Description

When creating a table with datatype float, this is not supported by the python library immudb-py.
As seen below.

Problem is present in the following file: https://github.com/codenotary/immudb-py/blob/master/immudb/typeconv.py#L29

Issue type

Bug

Overview

Table format:

CREATE DATABASE IF NOT EXISTS test;
CREATE TABLE IF NOT EXISTS products (
    id INTEGER AUTO_INCREMENT,
    product_name VARCHAR[100],
    price FLOAT,
    category_id INTEGER,
    barkeeper_percentage INTEGER,
    PRIMARY KEY (id)
);

Test data:

INSERT INTO products (product_name, price, category_id, barkeeper_percentage) VALUES
('Mojito', 12.50, 1, 10),
('Old Fashioned', 15.00, 1, 12),
('IPA Beer', 7.50, 2, 8),
('Merlot Wine', 10.00, 3, 10),
('Coke', 3.00, 4, 5);

Exception:

In [5]: client.sqlQuery("SELECT * FROM products",columnNameMode=True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 client.sqlQuery("SELECT * FROM products",columnNameMode=True)

File /usr/local/lib/python3.10/site-packages/immudb/client.py:1632, in ImmudbClient.sqlQuery(self, query, params, columnNameMode, acceptStream)
   1629 if acceptStream:
   1630     return it
-> 1632 return list(it)

File /usr/local/lib/python3.10/site-packages/immudb/handler/sqlquery.py:109, in RowIterator.__next__(self)
    108 def __next__(self):
--> 109     self._fetch_next()
    111     row = self._rows[self._nextRow]
    112     self._nextRow = self._nextRow+1

File /usr/local/lib/python3.10/site-packages/immudb/handler/sqlquery.py:126, in RowIterator._fetch_next(self)
    123 if self._columns == None:
    124     self._columns = getColumnNames(res, self._dbname, self._colsMode())
--> 126 self._rows = unpack_rows(
    127     res, self._colNameMode, self._columns)
    128 self._nextRow = 0
    130 if len(self._rows) == 0:

File /usr/local/lib/python3.10/site-packages/immudb/handler/sqlquery.py:55, in unpack_rows(resp, columnNameMode, colNames)
     52         result.append(tuple([sqlvalue_to_py(i) for i in row.values]))
     53     else:
     54         result.append(
---> 55             dict(zip(colNames, tuple([sqlvalue_to_py(i) for i in row.values]))))
     56 return result

File /usr/local/lib/python3.10/site-packages/immudb/handler/sqlquery.py:55, in <listcomp>(.0)
     52         result.append(tuple([sqlvalue_to_py(i) for i in row.values]))
     53     else:
     54         result.append(
---> 55             dict(zip(colNames, tuple([sqlvalue_to_py(i) for i in row.values]))))
     56 return result

File /usr/local/lib/python3.10/site-packages/immudb/typeconv.py:43, in sqlvalue_to_py(sqlValue)
     41     return None
     42 else:
---> 43     raise TypeError("Type not supported: {}".format(
     44         sqlValue.WhichOneof("value")))

TypeError: Type not supported: f

@ausarhuy
Copy link

ausarhuy commented Oct 3, 2024

I'm facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants