Commit 35a305c7 authored by Philippe Pebay's avatar Philippe Pebay
Browse files

ENH: make use of ostreamstrings when needed to construct SQLite queries too.

ENH: ignore size specification for numeric types
parent 798b510e
......@@ -25,11 +25,12 @@
#include "vtkStringArray.h"
#include <vtksys/SystemTools.hxx>
#include <vtksys/ios/sstream>
#include <vtksqlite/vtk_sqlite3.h>
vtkStandardNewMacro(vtkSQLiteDatabase);
vtkCxxRevisionMacro(vtkSQLiteDatabase, "1.12");
vtkCxxRevisionMacro(vtkSQLiteDatabase, "1.13");
// ----------------------------------------------------------------------
vtkSQLiteDatabase::vtkSQLiteDatabase()
......@@ -83,7 +84,8 @@ vtkStdString vtkSQLiteDatabase::GetColumnSpecification( vtkSQLDatabaseSchema* sc
int tblHandle,
int colHandle )
{
vtkStdString queryStr = schema->GetColumnNameFromHandle( tblHandle, colHandle );
vtksys_ios::ostringstream queryStr;
queryStr << schema->GetColumnNameFromHandle( tblHandle, colHandle );
// Figure out column type
int colType = schema->GetColumnTypeFromHandle( tblHandle, colHandle );
......@@ -91,7 +93,7 @@ vtkStdString vtkSQLiteDatabase::GetColumnSpecification( vtkSQLDatabaseSchema* sc
switch ( static_cast<vtkSQLDatabaseSchema::DatabaseColumnType>( colType ) )
{
case vtkSQLDatabaseSchema::SERIAL:
colTypeStr = 0;
colTypeStr = "";
break;
case vtkSQLDatabaseSchema::SMALLINT:
colTypeStr = "SMALLINT";
......@@ -129,8 +131,7 @@ vtkStdString vtkSQLiteDatabase::GetColumnSpecification( vtkSQLDatabaseSchema* sc
if ( colTypeStr.size() )
{
queryStr += " ";
queryStr += colTypeStr;
queryStr << " " << colTypeStr;
}
else // if ( colTypeStr.size() )
{
......@@ -147,25 +148,25 @@ vtkStdString vtkSQLiteDatabase::GetColumnSpecification( vtkSQLDatabaseSchema* sc
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::SMALLINT:
colSizeType = 1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::INTEGER:
colSizeType = 1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::BIGINT:
colSizeType = 1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::VARCHAR:
colSizeType = -1;
break;
case vtkSQLDatabaseSchema::TEXT:
colSizeType = -1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::REAL:
colSizeType = 1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::DOUBLE:
colSizeType = 1;
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::BLOB:
colSizeType = 0;
......@@ -197,20 +198,17 @@ vtkStdString vtkSQLiteDatabase::GetColumnSpecification( vtkSQLDatabaseSchema* sc
// if not required. Thus, skip sizing in the latter case.
if ( colSize > 0 )
{
queryStr += "(";
queryStr += colSize;
queryStr += ")";
queryStr << "(" << colSize << ")";
}
}
vtkStdString attStr = schema->GetColumnAttributesFromHandle( tblHandle, colHandle );
if ( attStr.size() )
{
queryStr += " ";
queryStr += attStr;
queryStr << " " << attStr;
}
return queryStr;
return queryStr.str();
}
// ----------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment