Changeset 14396
- Timestamp:
- 05/08/08 12:27:19 (2 months ago)
- Files:
-
- trunk/autotest/ogr/ogr_sqlite.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/autotest/ogr/ogr_sqlite.py
r14395 r14396 122 122 return 'skip' 123 123 124 if gdaltest.sl_lyr.GetFeatureCount() != 10: 125 gdaltest.post_reason( 'GetFeatureCount() returned %d instead of 10' % gdaltest.sl_lyr.GetFeatureCount() ) 126 return 'fail' 127 124 128 expect = [168, 169, 166, 158, 165] 125 129 … … 127 131 tr = ogrtest.check_features_against_list( gdaltest.sl_lyr, 128 132 'eas_id', expect ) 133 134 if gdaltest.sl_lyr.GetFeatureCount() != 5: 135 gdaltest.post_reason( 'GetFeatureCount() returned %d instead of 5' % gdaltest.sl_lyr.GetFeatureCount() ) 136 return 'fail' 137 129 138 gdaltest.sl_lyr.SetAttributeFilter( None ) 130 139 … … 214 223 215 224 sql_lyr = gdaltest.sl_ds.ExecuteSQL( 'select distinct eas_id from tpoly order by eas_id desc' ) 225 226 if sql_lyr.GetFeatureCount() != 11: 227 gdaltest.post_reason( 'GetFeatureCount() returned %d instead of 11' % sql_lyr.GetFeatureCount() ) 228 return 'fail' 216 229 217 230 tr = ogrtest.check_features_against_list( sql_lyr, 'eas_id', expect ) … … 263 276 gdaltest.sl_lyr.SetSpatialFilter( geom ) 264 277 geom.Destroy() 265 278 279 if gdaltest.sl_lyr.GetFeatureCount() != 1: 280 gdaltest.post_reason( 'GetFeatureCount() returned %d instead of 1' % gdaltest.sl_lyr.GetFeatureCount() ) 281 return 'fail' 282 266 283 tr = ogrtest.check_features_against_list( gdaltest.sl_lyr, 'eas_id', 267 284 [ 158 ] ) 285 286 gdaltest.sl_lyr.SetAttributeFilter( 'eas_id = 158' ) 287 288 if gdaltest.sl_lyr.GetFeatureCount() != 1: 289 gdaltest.post_reason( 'GetFeatureCount() returned %d instead of 1' % gdaltest.sl_lyr.GetFeatureCount() ) 290 return 'fail' 291 292 gdaltest.sl_lyr.SetAttributeFilter( None ) 268 293 269 294 gdaltest.sl_lyr.SetSpatialFilter( None ) … … 490 515 feat_read.Destroy() 491 516 517 feat_read = sql_lyr.GetFeature(0) 518 if ogrtest.check_feature_geometry(feat_read,geom,max_error = 0.001 ) != 0: 519 return 'fail' 520 feat_read.Destroy() 521 492 522 gdaltest.sl_ds.ReleaseResultSet( sql_lyr ) 493 523 … … 532 562 return 'success' 533 563 564 565 ############################################################################### 566 # Test all column types 567 568 def ogr_sqlite_14(): 569 570 if gdaltest.sl_ds is None: 571 return 'skip' 572 573 gdaltest.sl_lyr = gdaltest.sl_ds.CreateLayer( 'testtypes' ) 574 ogrtest.quick_create_layer_def( gdaltest.sl_lyr, 575 [ ('INTEGER', ogr.OFTInteger), 576 ('FLOAT', ogr.OFTReal), 577 ('STRING', ogr.OFTString), 578 ('BLOB', ogr.OFTBinary), 579 ('BLOB2', ogr.OFTBinary) ] ) 580 581 dst_feat = ogr.Feature( feature_def = gdaltest.sl_lyr.GetLayerDefn() ) 582 583 dst_feat.SetField('INTEGER', 1) 584 dst_feat.SetField('FLOAT', 1.2) 585 dst_feat.SetField('STRING', 'myString\'a') 586 587 gdaltest.sl_lyr.CreateFeature( dst_feat ) 588 589 dst_feat.Destroy() 590 591 # Set the BLOB attribute via SQL UPDATE instructions as there's no binding 592 # for OGR_F_SetFieldBinary 593 gdaltest.sl_ds.ExecuteSQL("UPDATE testtypes SET BLOB = x'0001FF' WHERE OGC_FID = 1") 594 595 ###################################################### 596 # Reopen DB 597 gdaltest.sl_ds.Destroy() 598 gdaltest.sl_ds = ogr.Open( 'tmp/sqlite_test.db' ) 599 gdaltest.sl_lyr = gdaltest.sl_ds.GetLayerByName('testtypes') 600 601 # Duplicate the first record 602 dst_feat = ogr.Feature( feature_def = gdaltest.sl_lyr.GetLayerDefn() ) 603 feat_read = gdaltest.sl_lyr.GetNextFeature() 604 dst_feat.SetFrom(feat_read) 605 gdaltest.sl_lyr.CreateFeature( dst_feat ) 606 dst_feat.Destroy() 607 608 # Check the 2 records 609 gdaltest.sl_lyr.ResetReading() 610 for i in range(2): 611 feat_read = gdaltest.sl_lyr.GetNextFeature() 612 if feat_read.GetField('INTEGER') != 1 or \ 613 feat_read.GetField('FLOAT') != 1.2 or \ 614 feat_read.GetField('STRING') != 'myString\'a' or \ 615 feat_read.GetFieldAsString('BLOB') != '0001FF': 616 return 'fail' 617 618 gdaltest.sl_lyr.ResetReading() 619 620 return 'success' 534 621 535 622 ############################################################################### … … 546 633 gdaltest.sl_ds.ExecuteSQL( 'DELLAYER:wgs84layer' ) 547 634 gdaltest.sl_ds.ExecuteSQL( 'DELLAYER:wgs84layer_approx' ) 635 gdaltest.sl_ds.ExecuteSQL( 'DELLAYER:testtypes' ) 548 636 549 637 gdaltest.sl_ds.Destroy() … … 571 659 ogr_sqlite_12, 572 660 ogr_sqlite_13, 661 ogr_sqlite_14, 573 662 ogr_sqlite_cleanup ] 574 663
