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

Table name is case sensitive in parameter binding statement - WebSocket client #260

Open
jond01 opened this issue Sep 22, 2024 · 0 comments

Comments

@jond01
Copy link

jond01 commented Sep 22, 2024

  • TDEngine server version: 3.3.2.0 (SELECT server_version();).
  • Python taos-ws-py client version: 0.3.3 (import taosws; print(taosws.__version__)).
  • Python version: 3.9.19.

I use the taosws client and write data with parameter binding. Setting the table name fails when the name includes uppercase letters.

from datetime import datetime, timezone

import taosws

TABLE_NAME = "lowUP"

conn = taosws.connect("taosws://root:taosdata@localhost:6041")
conn.execute("CREATE DATABASE IF NOT EXISTS t0;")
conn.execute("USE t0;")

conn.execute(f"CREATE TABLE {TABLE_NAME} (time TIMESTAMP, val INT);")
print(f'{list(conn.query("SHOW TABLES;")) = }')

# Standard insertion
conn.execute(f"INSERT INTO {TABLE_NAME} VALUES (now(), 0);")

# Select the data
print(f'{list(conn.query(f"SELECT * FROM {TABLE_NAME};")) =}')

# Parameter bound insertion
stmt = conn.statement()
stmt.prepare("INSERT INTO ? VALUES (?, ?);")
stmt.set_tbname(TABLE_NAME)  # <-- this line errors

stmt.bind_param(
    [
        taosws.millis_timestamps_to_column([int(datetime.now(tz=timezone.utc).timestamp() * 1000)]),
        taosws.ints_to_column([2]),
    ]
)

stmt.add_batch()
stmt.execute()

print(f'{list(conn.query(f"SELECT * FROM {TABLE_NAME};")) =}')

Error:

ProgrammingError: [0x2603] Internal error: `Table does not exist`

When TABLE_NAME is lowercase only, e.g. "low", the snippet passes.

I expect it to work since TDEngine table names are case-insensitive:

Names are case insensitive.

https://docs.tdengine.com/reference/taos-sql/limit/#restrictions-of-tablecolumn-names

I found that escaping the table name with `` works:

TABLE_NAME = "`lowUP`"

Still, the current behavior is unexpected.

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

1 participant