File tree 3 files changed +12
-6
lines changed
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,6 @@ environment:
23
23
- arch : Win32
24
24
- arch : Win64
25
25
26
- matrix :
27
- allow_failures :
28
- - image : Visual Studio 2013
29
-
30
26
init :
31
27
- echo %APPVEYOR_BUILD_WORKER_IMAGE% - %configuration% - %arch%
32
28
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set vs=Visual Studio 15 2017)
Original file line number Diff line number Diff line change @@ -224,12 +224,16 @@ class Column
224
224
return getBlob ();
225
225
}
226
226
227
- #if !( defined(_MSC_VER) && _MSC_VER < 1900)
227
+ #if !defined(_MSC_VER) || _MSC_VER >= 1900
228
228
// NOTE : the following is required by GCC and Clang to cast a Column result in a std::string
229
229
// (error: conversion from ‘SQLite::Column’ to non-scalar type ‘std::string {aka std::basic_string<char>}’)
230
+ // and also required for Microsoft Visual Studio 2015 and newer
230
231
// but is not working under Microsoft Visual Studio 2010, 2012 and 2013
231
232
// (error C2440: 'initializing' : cannot convert from 'SQLite::Column' to 'std::basic_string<_Elem,_Traits,_Ax>'
232
233
// [...] constructor overload resolution was ambiguous)
234
+ // WARNING: without it, trying to access a binary blob with implicit cast to string
235
+ // ends up converting it to a C-style char*, damaging the data by truncating it to the first null character!
236
+ // (see https://github.com/SRombauts/SQLiteCpp/issues/189 Visual Studio 2013: unit test "Column.basis" failing)
233
237
/* *
234
238
* @brief Inline cast operator to std::string
235
239
*
Original file line number Diff line number Diff line change @@ -68,7 +68,11 @@ TEST(Column, basis) {
68
68
const int integer = query.getColumn (2 ); // operator int()
69
69
const double real = query.getColumn (3 ); // operator double()
70
70
const void * pblob = query.getColumn (4 ); // operator void*()
71
- const std::string sblob = query.getColumn (4 ); // operator std::string() (or const char* with MSVC)
71
+ #if !defined(_MSC_VER) || _MSC_VER >= 1900
72
+ // This implicit cast should use operator std::string()
73
+ // but would fallback to const char* with MSVC 2010-2013 (witch does not work with the NULL char in the middle)
74
+ const std::string sblob = query.getColumn (4 ); // operator std::string()
75
+ #endif
72
76
const void * pempty = query.getColumn (5 ); // operator void*()
73
77
EXPECT_EQ (1 , id1);
74
78
EXPECT_EQ (1 , id2);
@@ -81,8 +85,10 @@ TEST(Column, basis) {
81
85
EXPECT_EQ (-123 , integer);
82
86
EXPECT_EQ (0.123 , real);
83
87
EXPECT_EQ (0 , memcmp (" bl\0 b" , pblob, size));
88
+ #if !defined(_MSC_VER) || _MSC_VER >= 1900
84
89
EXPECT_EQ ((size_t )size, sblob.size ());
85
90
EXPECT_EQ (0 , memcmp (" bl\0 b" , &sblob[0 ], size));
91
+ #endif
86
92
EXPECT_EQ (NULL , pempty);
87
93
}
88
94
You can’t perform that action at this time.
0 commit comments