Skip to content

'testtable' is not a function: SQL logic error #1186

@raidenluikang

Description

@raidenluikang

Following example success compiled with latest dev sqlite_orm, but on runtime gives 'testtable' is not a function: SQL logic error

#include <cstdint>
#include <string>

#include "sqlite_orm_dev.h"

namespace orm = sqlite_orm;



struct testtable
{
    std::int64_t id = 0;
    std::int64_t value = 0;
};

static inline auto init_storage(const std::string &path){
    
    return orm::make_storage(path,
			orm::make_table("testtable",
                            orm::make_column("id", &testtable::id, /*orm::autoincrement(),*/ orm::primary_key().autoincrement()),
                            orm::make_column("value", &testtable::value)
                        )
    );
}

using storage_t = decltype(init_storage(""));

int main(){

    storage_t storage = init_storage("database.sql");
    storage.sync_schema();
	testtable table;
	table.id = 20;
	table.value = 1;
	storage.replace<testtable>(table);
    auto list = storage.get_all<testtable>(
            //orm::where( //--> Imagine that, I forgotten write there orm::where
                orm::and_(orm::is_equal(&testtable::id, 20),
                           orm::is_equal(&testtable::value, 1)
                                  
                ),
            //),
            orm::limit( 1 ) 
            );
    
    for (auto&& row : list)
    {
		printf("id = %lld value = %lld\n", (long long)row.id, (long long)row.value);
	}
    return 0;
}

OUTPUT:

$ ./main
terminate called after throwing an instance of 'std::system_error'
  what():  'testtable' is not a function: SQL logic error
Aborted (core dumped)

Q: Can be detect this error in compile time ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions