Closed jeffrosenthal closed 6 years ago
Good job. Please make a pull request to make it more comfortable to analyze and merge
@jeffrosenthal I'm trying to implement what you want and facing a problem - text encoding. Using std::wstring
means you are storing your text in your domain model in UTF16 and SQLite stores string in UTF8. So either we need an encoder/decoder or we must change task's meaning
@jeffrosenthal please check out the latest commit - I've added std::wstring
full support. Now sqlite_orm
encodes wide strings to UTF8 before inserting and decodes it back to UTF16 on select. Also I've added tests for several unicode alphabets (arabic, armenian, russian and turkish)
If it is ok for you please close the issue.
ty
@jeffrosenthal tell me please what compiler do you use and what OS. CI of this lib fails cause it can not find <codecvt>
header on ubuntu but everything works fine on my mac
This was on Windows vs2015
Sent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------From: Yevgeniy Zakharov notifications@github.com Date: 2/5/18 05:52 (GMT-05:00) To: fnc12/sqlite_orm sqlite_orm@noreply.github.com Cc: jeffrosenthal jeff@thecodingpit.com, Mention mention@noreply.github.com Subject: Re: [fnc12/sqlite_orm] wstring support (#83)
@jeffrosenthal tell me please what compiler do you use and what OS. CI of this lib fails cause it can not find
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/fnc12/sqlite_orm","title":"fnc12/sqlite_orm","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/fnc12/sqlite_orm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@fnc12 in #83: @jeffrosenthal tell me please what compiler do you use and what OS. CI of this lib fails cause it can not find \u003ccodecvt\u003e
header on ubuntu but everything works fine on my mac"}],"action":{"name":"View Issue","url":"https://github.com/fnc12/sqlite_orm/issues/83#issuecomment-363049536"}}}
Note: <codecvt>
is not supported by gcc until gcc 5. This prevents some people from using the library unless they update to the latest gcc.
I had similar compile problem with the header.
@sschweigert I understand. What can I do for you except advising switching from gcc
to clang
?
I found that the code does not support wstrings. I otherwise like what you have done. I modified the code to support it if you would like it. `
ifndef sqlite_orm_h
define sqlite_orm_h
include
include
include
include "..\sqlite3.h"
include
include // std::vector
include // std::stringstream
include // std::find
include // std::shared_ptr, std::unique_ptr
include
include
include
include // std::set
include // std::function
include // std::ostream
include // std::iterator_traits
include
include
if defined(_MSC_VER)
if defined(min)
__pragma(push_macro("min"))
undef min
define __RESTORE_MIN__
endif
if defined(max)
__pragma(push_macro("max"))
undef max
define __RESTORE_MAX__
endif
endif // defined(_MSC_VER)
namespace sqlite_orm {
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3006019
endif
// NUMERIC, // numeric and real are the same for c++ };
// std::regex("INTEGER"), std::regex("TINYINT"), std::regex("SMALLINT"), std::regex("MEDIUMINT"), std::regex("BIGINT"), std::regex("UNSIGNED BIG INT"), std::regex("INT2"), std::regex("INT8"), } }, { sqlite_type::TEXT, { std::regex("CHARACTER\([[:digit:]]+\)"), std::regex("VARCHAR\([[:digit:]]+\)"), std::regex("VARYING CHARACTER\([[:digit:]]+\)"), std::regex("NCHAR\([[:digit:]]+\)"), std::regex("NATIVE CHARACTER\([[:digit:]]+\)"), std::regex("NVARCHAR\([[:digit:]]+\)"), std::regex("CLOB"), std::regex("TEXT"), } }, { sqlite_type::BLOB, { std::regex("BLOB"), } }, { sqlite_type::REAL, { std::regex("REAL"), std::regex("DOUBLE"), std::regex("DOUBLE PRECISION"), std::regex("FLOAT"), std::regex("NUMERIC"), std::regex("DECIMAL\([[:digit:]]+,[[:digit:]]+\)"), std::regex("BOOLEAN"), std::regex("DATE"), std::regex("DATETIME"), } }, }; for(auto &p : typeMap) { for(auto &r : p.second) { if(std::regex_match(upperStr, r)){ return std::make_shared(p.first);
}
}
}
// return {this, internal::collate_argument::nocase}; auto res = this; res._collate_argument = std::make_unique(internal::collate_argument::nocase);
return res;
}
// return {this, internal::collate_argument::rtrim}; auto res = this; res._collate_argument = std::make_unique(internal::collate_argument::rtrim);
return res;
}
};
if SQLITE_VERSION_NUMBER >= 3007016
endif
if SQLITE_VERSION_NUMBER >= 3007016
endif
// this->apply_to_col_if(l, internal::is_column{});
Super::for_each_column_with_constraints(l);
}
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3007016
endif
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3007016
endif
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3007016
endif
if SQLITE_VERSION_NUMBER >= 3006019
endif
if SQLITE_VERSION_NUMBER >= 3007010
endif
}
if defined(_MSC_VER)
if defined(__RESTORE_MIN__)
__pragma(pop_macro("min"))
undef __RESTORE_MIN__
endif
if defined(__RESTORE_MAX__)
__pragma(pop_macro("max"))
undef __RESTORE_MAX__
endif
endif // defined(_MSC_VER)
endif / sqlite_orm_h /
`