Skip to content

Exception: Could not determine declared column type #516

Description

@fumanchi

Hi...

SQLiteCpp has its issues with my (otherwise correct) queries. The following query has already been improved by type cast expressions in the form of "CAST(() AS INT)" but still does trigger an SQLite::Exception "Could not determine declared column type":

SELECT DISTINCT T_0.gnsorm_id,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_outputs AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_outputs_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_inputs AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_inputs_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_models AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_models_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_groups AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_groups_0,
                T_0.name
FROM GNS_CDISScope_GNS_CDIIndexGroup AS T_0
WHERE (T_0.gnsorm_id = 1)
ORDER BY T_0.gnsorm_id

The query is generated by an object relational mapping. The query (even w/o these CASTs) is running fine via Qt sql abstraction on a sqlite database.

Executing this query via sqlitebrowser on the same databse results in:

Execution finished without errors.
Result: 0 rows returned in 4ms
At line 1:
SELECT DISTINCT T_0.gnsorm_id,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_outputs AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_outputs_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_inputs AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_inputs_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_models AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_models_0,
                CAST(
                       (SELECT COUNT(T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)
                        FROM GNS_CDISScope_GNS_CDIIndexGroup_groups AS T_0
                        WHERE (T_0.gnsorm_id = T_0.gnsorm_fk_GNS_CDISScope_GNS_CDIIndexGroup_owner)) AS INT) AS COUNT_LAZY_groups_0,
                T_[0.name](http://0.name/)
FROM GNS_CDISScope_GNS_CDIIndexGroup AS T_0
WHERE (T_0.gnsorm_id = 1)
ORDER BY T_0.gnsorm_id

An empty resultset... Which was expected :)... but no errors at all...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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