Comments (24)
You forked the lib - this is correct. Next step - modify code and commit & push it. Next go to your fork page on github and press Send pull request
button. I'll receive your pull request and accept or deny it. Thanks
from sqlite_orm.
@Ninja-007 btw you can discuss improvements here. Please tell me what do you miss in the lib and I'll assist you or improve it. Thanks
from sqlite_orm.
Thanks for your reply. It is very nice.
- Usage of cout directly in library is not good. In my application, only application supposed to do cout. The library can use callback function(registered by application during initialisation) for logging. If logging is enabled, then application can log the messages from lib else can ignore it. It is upto application to decide which messages to display.
- Usage of uint8_t, uint16_t, uint32_t and int8_t as datatypes. I have some classes which I cannot change and datatype of classmembers should reflect allowed range. (I added code for this.)
- Replacing std::to_string with std::stringstream usage or better alternative. On some compliers the function is not present. ((I added code for this.)
Regards
from sqlite_orm.
Oh thanks. Please push your changes to your repo and create a pull request. Points 1 and 3 are very good. But there is a thing about point 2. uint8_t
are not language types but typedef
s so we'd better add unsigned
data types support so uint8_t
, uint16_t
, uint32_t
and int8_t
will be supported too.
from sqlite_orm.
I just did pull request. Did you receive it?
from sqlite_orm.
@Ninja-007 yes I did. Thanks. You did right. Let me inspect it a little bit and then I'll write you back.
from sqlite_orm.
New requests. If you have alternative, then add write here.
- Utilty functions
- bool IsDBPresent(const std::string& DBPath) //will verify presence of DB on disk
- bool Storage.IsTablePresent(const std::string& TableName) //will verify presence of table on in given storage intance(returned by make_storage)
- bool UserClass.IsRowPresent(T primarykey) //verifies presence of row in UserClass attached table
- Renaming Storage.replace to insert_with_id to avoid confusion and understand usage from name.
- Renaming Storage.insert to insert_make_id to avoid confusion and understand usage from name.
from sqlite_orm.
bool IsDBPresent(const std::string& DBPath)
why? What are you going to perform is db exists? What if not?bool Storage.IsTablePresent(const std::string& TableName)
same question. I assumesync_schema
is enoughbool UserClass.IsRowPresent(T primarykey)
why? What use cases do you expect with it?
Storage::replace
is namedreplace
causeSQLite
has queryREPLACE
. Details hereStorage::insert
doesn't create id in all cases - it created id if primary key column isint
. But if primary key isstd::string
for example it doesn't. To be exactStorage::insert
returns last insert row id. So I don't think we need to rename these functions.Replace
needs primary key anyway. So theninsert
is the only way to insert without primary key.
from sqlite_orm.
@Ninja-007 why do you use unary plus operator before adding object to stream like this:
std::stringstream stream;
stream << +t;
return stream.str();
?
from sqlite_orm.
To get numerical values instead ASCII characters
https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout
from sqlite_orm.
@Ninja-007 wow nice way. I do static_cast
in this cases. Ok I leave it.
from sqlite_orm.
Thanks,
I have to write some default values in table if it is initilized for first time. When table is present, then nothing should be done. This should be done before doing sync_schema.
BTW, I wrote IsDBPresent and IsTablePresent, if you ready to integrate then I can push the code.
from sqlite_orm.
I checked you recent checkin.
There is code like
// char is neigher signer char nor unsigned char so it has its own specialization
template<>
struct field_printer {
std::string operator()(const signed char &t) const {
std::stringstream stream;
stream << +t;
return stream.str();
}
};
You have wrote signed char in function defination. Is that expected?
from sqlite_orm.
@Ninja-007 default values can be added with default_value
constraint in make_column
function. Then call sync_schema
and:
- table will be added if it doesn't exist with with
DEFAULT
in specified columns - noting will be done if table already exists with the same schema
- table will be altered or recreated if table exists with different schema
About field_printer's char
specialization:
yes, I missed argument type in operator()
. Thanks
from sqlite_orm.
There is no need in IsDBPresent
and IsTablePresent
- storage is designed to be static
from sqlite_orm.
@Ninja-007 what do you mean IsDBPresent
? What does it returns? Whether file exists? Or whether all tables exist with a given schema?
from sqlite_orm.
I added simple function which checks for existence of file.
/*!
\fn IsDBPresent
\brief verifies presence of database file on disk.
\warning the file may not be valid sqlite database.
*/
static bool IsDBPresent(const std::string& DBPath);
{
struct stat buffer;
return (stat (DBPath.c_str(), &buffer) == 0);
}
from sqlite_orm.
I am made pull request to fix complier warnings. Warnings in library are not good.
from sqlite_orm.
checking file existence can be implemented in file system libraries: boost fs or it's C++17 standard analog. Or one can use libc for this with FILE *file = fopen("path.db");
. Also file system interaction differs on different operating systems and this is not about sqlite at all. Also there can be any other file (image probably) with the same name just accidentally but IsDBPresent
returns true
and this is not correct cause this file has nothing common with database. sync_schema
is a better way to perform file and schema check.
Warnings will be fixed. Thanks
from sqlite_orm.
You have very good library. But I donot find some many forks or users of this library.
Would you mind to submit this lib to https://github.com/fffaraz/awesome-cpp ?
from sqlite_orm.
Thanks. I'd like to. I've already tried to submit there about two or three times. But pull request wasn't accepted with no comments. Maybe you should try?
from sqlite_orm.
You should raise issue for that. I am not sure about pull request. Once you raise issue, let me know. I shall comment there.
from sqlite_orm.
Looks like sqlite_orm
got its place in awesome cpp repos. Are there any other issues within it? @Ninja-007
from sqlite_orm.
closing due to inactivity
from sqlite_orm.
Related Issues (20)
- Templated Storage Schema - Compilation Issues HOT 10
- 怎样定义 make_storage 返回模板类型 的 c++类成员变量 HOT 1
- "no such table" error on existing database HOT 1
- Delete a foreign key HOT 5
- sqlite-orm fails to compile under uwp HOT 5
- C:\src\sqlite_orm\tests\schema\virtual_table.cpp(6): exception: no such module: FTS5: SQL logic error HOT 2
- I need to store a vector of vector<std::string> as a field in a persistent class, how can I do this? HOT 8
- add column sync_schema will recreate table HOT 12
- compile error with gcc 5.3.1 HOT 6
- Windows linker error SQLite3 HOT 3
- Warning on CMake >= 3.27 because of support for CMake >= 2.8.12
- Cannot Build my project HOT 2
- `SQLITE_DQS` Compile Option HOT 7
- Failed to compile origin/dev branch using GCC 8.3 HOT 2
- Do not understand select statement generation HOT 3
- Support for returning objects inside columns HOT 6
- Corrupted Databases HOT 10
- API has changed a bit : what is c<Type>? HOT 1
- why is this WITH not recursive? HOT 2
- FTS5 Options: Unindexed columns, prefix indexes, tokenizers & content HOT 25
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite_orm.