Skip to content

Commit

Permalink
chore(ODBC): add compile time big string diagnostics #4324
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Oct 16, 2024
1 parent c5c00ef commit b8dd1a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Data/ODBC/src/Binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ void Binder::getColSizeAndPrecision(std::size_t pos,
bool foundSize(false);
bool foundPrec(false);

// SQLServer driver reports COLUMN_SIZE 8000 for VARCHAR(MAX),
// so the size check must be skipped when big strings are enabled
#ifdef POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT
bool isVarchar(false);
switch (sqlDataType)
Expand Down
7 changes: 7 additions & 0 deletions Data/ODBC/src/Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
#include "Poco/Data/SessionFactory.h"


#if POCO_DATA_SQL_SERVER_BIG_STRINGS
#pragma message ("MS SQLServer ODBC big string capability ENABLED")
#else
#pragma message ("MS SQLServer ODBC big string capability DISABLED")
#endif


namespace Poco {
namespace Data {
namespace ODBC {
Expand Down
7 changes: 7 additions & 0 deletions Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ using Poco::DateTime;
#endif
#endif

#if POCO_DATA_SQL_SERVER_BIG_STRINGS
#pragma message ("MS SQLServer ODBC big string capability ENABLED")
#else
#pragma message ("MS SQLServer ODBC big string capability DISABLED")
#endif

#define MS_SQL_SERVER_DSN "PocoDataSQLServerTest"
#define MS_SQL_SERVER_SERVER POCO_ODBC_TEST_DATABASE_SERVER
#define MS_SQL_SERVER_PORT "1433"
Expand Down Expand Up @@ -241,6 +247,7 @@ void ODBCSQLServerTest::testBigString()
firstName.clear();
address.clear();
age = 0;

session() << "SELECT LastName /*VARCHAR(MAX)*/, FirstName /*VARCHAR(8000)*/, Address /*VARCHAR(30)*/, Age FROM Person"s,
into(lastName), into(firstName), into(address), into(age), now;

Expand Down

0 comments on commit b8dd1a9

Please sign in to comment.