Skip to content

Allow NodeJS driver to apply automatic type conversion in query parameters #242

Description

@josiahjohnston

The NodeJS cassandra driver offers automatic & safe type conversion for prepared queries.
This is great for simpler code that doesn't have to convert strings to UUID types, dates, etc.
Ex:

cql_client.execute(
    'SELECT * FROM keyspace.sample_table where "id" = ?;', 
    [ 'd8160520-5f6d-11eb-af42-0a1f69b793a6'], 
    { prepare : true }
).then(dat => {console.log(`results obtained: ${dat.length}`); }
).catch(error => console.log(`got error ${error}`));

Express Cassandra prepares all queries by default, so I expected this feature to be available.
But when I try to query with a string UUID instead of a UUID type, I get an error because string isn't a UUID type. The error is thrown by lib/utils/parser.js get_db_value_expression(). This forces me to write queries like models.datatypes.Uuid.fromString(id) instead of id.

Is there some way to bypass that type checking? If not, would you consider supporting that feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions