8000 Non-standart primary key checking by denzor200 · Pull Request #644 · fnc12/sqlite_orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Non-standart primary key checking #644

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

Merged
merged 24 commits into from
Mar 5, 2021
Merged

Conversation

denzor200
Copy link
Contributor
@denzor200 denzor200 commented Jan 16, 2021

This pull request adds a useful compile-time error. You can reproduce it with a simple example:

#include <sqlite_orm/sqlite_orm.h>

using namespace sqlite_orm;

struct User {
    std::string username;
    std::string password;
    bool isActive;
};

int main()
{
    auto storage = make_storage("storage.sqlite", ///
        make_table("users", ///
            make_column("username", &User::username, primary_key()),
            make_column("password", &User::password),
            make_column("isActive", &User::isActive)));
    storage.sync_schema();

    storage.insert(User { "testName", "testPassword2", false });

    return 0;
}

In the current sqlite_orm, this example throws a runtime error "NOT NULL constraint failed", which is somewhat misleading.

@denzor200
Copy link
Contributor Author

not tested under Windows .. Tomorrow I will fix it all

@denzor200 denzor200 force-pushed the PRIMARY_NO_DEF_INSERT branch from cf24f0e to c977f4d Compare January 16, 2021 19:24
@denzor200 denzor200 marked this pull request as draft January 16, 2021 19:56
@denzor200 denzor200 marked this pull request as ready for review January 16, 2021 20:05
@denzor200
Copy link
Contributor Author

@fnc12, fixed

@denzor200 denzor200 marked this pull request as draft January 28, 2021 19:56
@denzor200 denzor200 force-pushed the PRIMARY_NO_DEF_INSERT branch from 0dbf521 to 25da2b7 Compare February 5, 2021 19:15
@denzor200 denzor200 force-pushed the PRIMARY_NO_DEF_INSERT branch from 5b47e2e to 5c9f9e9 Compare February 26, 2021 08:54
 Conflicts:
	dev/statement_serializator.h
	dev/storage.h
	include/sqlite_orm/sqlite_orm.h
@denzor200 denzor200 force-pushed the PRIMARY_NO_DEF_INSERT branch from 7c08996 to a455026 Compare February 26, 2021 10:43
@denzor200 denzor200 marked this pull request as ready for review February 27, 2021 13:37
@denzor200 denzor200 requested a review from fnc12 February 27, 2021 13:39
Copy link
Owner
@fnc12 fnc12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix and/or reply to all comments before merging

* Table interface class with 'without_rowid' tag. Implementation is hidden in `table_impl` class.
*/
template<class T, class... Cs>
struct table_without_rowid_t : table_template<T, true, Cs...> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to split table in two classes? We can just have a template bool arg in table_t class instead of two table classes

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still actual

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should leave table_without_rowid_t, beacause "a template bool arg in table_t class" may deliver some small problems for users.
For example, lets see section "Slow & size effective"
https://github.com/fnc12/sqlite_orm/wiki/FAQ

bool isActive;
};

auto storage = make_storage({}, ///
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: strange comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for control over clang-format

@fnc12 fnc12 merged commit 707424a into fnc12:dev Mar 5, 2021
@fnc12
Copy link
Owner
fnc12 commented Mar 5, 2021

@denzor200 thanks

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

Successfully merging this pull request may close these issues.

2 participants
0