Changeset 11484
- Timestamp:
- 05/11/07 12:41:01 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp
r10645 r11484 308 308 if( sqlite3_column_type( hStmt, iRawField ) == SQLITE_NULL ) 309 309 continue; 310 310 311 311 switch( poFieldDefn->GetType() ) 312 312 { 313 case OFTInteger:313 case OFTInteger: 314 314 poFeature->SetField( iField, 315 sqlite3_column_int( hStmt, iRawField ) );316 break; 317 318 case OFTReal:315 sqlite3_column_int( hStmt, iRawField ) ); 316 break; 317 318 case OFTReal: 319 319 poFeature->SetField( iField, 320 sqlite3_column_double( hStmt, iRawField ) ); 321 break; 322 323 #ifdef notdef 324 case OFTBinary: 325 { 326 int nBytes = sqlite3_column_bytes( hStmt, iRawField ); 327 328 poFeature->SetField( iField, 329 sqlite3_column_double( hStmt, iRawField ) ); 330 } 331 break; 332 #endif 333 334 case OFTString: 320 sqlite3_column_double( hStmt, iRawField ) ); 321 break; 322 323 case OFTBinary: 324 { 325 const int nBytes = sqlite3_column_bytes( hStmt, iRawField ); 326 327 poFeature->SetField( iField, nBytes, 328 (GByte*)sqlite3_column_blob( hStmt, iRawField ) ); 329 } 330 break; 331 332 case OFTString: 335 333 poFeature->SetField( iField, 336 (const char *)337 sqlite3_column_text( hStmt, iRawField ) );338 break; 339 340 default:334 (const char *) 335 sqlite3_column_text( hStmt, iRawField ) ); 336 break; 337 338 default: 341 339 break; 342 340 } trunk/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp
r10645 r11484 412 412 413 413 /* -------------------------------------------------------------------- */ 414 /* Do we want to "launder" the column names into Postgres*/414 /* Do we want to "launder" the column names into SQLite */ 415 415 /* friendly format? */ 416 416 /* -------------------------------------------------------------------- */ … … 424 424 425 425 /* -------------------------------------------------------------------- */ 426 /* Work out the PostgreSQL type.*/426 /* Work out the SQLite type. */ 427 427 /* -------------------------------------------------------------------- */ 428 428 if( oField.GetType() == OFTInteger ) … … 433 433 { 434 434 strcpy( szFieldType, "FLOAT" ); 435 } 436 else if( oField.GetType() == OFTBinary ) 437 { 438 strcpy( szFieldType, "BLOB" ); 435 439 } 436 440 else … … 484 488 else if( poFldDefn->GetType() == OFTReal ) 485 489 pszType = "FLOAT"; 490 else if( poFldDefn->GetType() == OFTBinary ) 491 pszType = "BLOB"; 486 492 else 487 493 pszType = "VARCHAR"; … … 503 509 else if( oField.GetType() == OFTReal ) 504 510 pszType = "FLOAT"; 511 else if( oField.GetType() == OFTBinary ) 512 pszType = "BLOB"; 505 513 else 506 514 pszType = "VARCHAR"; … … 740 748 oCommand += "'"; 741 749 742 pszRawValue = poFeature->GetFieldAsString( iField ); 743 if( strchr( pszRawValue, '\'' ) != NULL ) 750 if( poFeatureDefn->GetFieldDefn(iField)->GetType() == OFTBinary ) 744 751 { 745 char *pszEscapedValue = 746 CPLEscapeString( pszRawValue, -1, CPLES_SQL ); 752 int binaryCount = 0; 753 GByte* binaryData = poFeature->GetFieldAsBinary( iField, &binaryCount ); 754 char* pszHexValue = CPLBinaryToHex( binaryCount, binaryData ); 755 oValues += "X'"; 756 oValues += pszHexValue; 747 757 oValues += "'"; 748 oValues += pszEscapedValue; 749 oValues += "'"; 750 751 CPLFree( pszEscapedValue ); 758 CPLFree( pszHexValue ); 752 759 } 753 760 else 754 761 { 755 oValues += "'"; 756 oValues += pszRawValue; 757 oValues += "'"; 762 pszRawValue = poFeature->GetFieldAsString( iField ); 763 764 if( strchr( pszRawValue, '\'' ) != NULL ) 765 { 766 char *pszEscapedValue = 767 CPLEscapeString( pszRawValue, -1, CPLES_SQL ); 768 oValues += "'"; 769 oValues += pszEscapedValue; 770 oValues += "'"; 771 772 CPLFree( pszEscapedValue ); 773 } 774 else 775 { 776 oValues += "'"; 777 oValues += pszRawValue; 778 oValues += "'"; 779 } 758 780 } 759 781 760 782 bNeedComma = TRUE; 761 783 } … … 797 819 } 798 820 821
