@@ -2312,38 +2312,40 @@ public function testStringTypeAttributes(): void
23122312 $ this ->assertEquals (['test1 ' , 'test2 ' , 'test3 ' ], $ doc3 ->getAttribute ('varchar_array ' ));
23132313 $ this ->assertEquals ([\str_repeat ('x ' , 1000 ), \str_repeat ('y ' , 2000 )], $ doc3 ->getAttribute ('text_array ' ));
23142314
2315- // Test VARCHAR size constraint (should fail)
2316- try {
2317- $ database ->createDocument ('stringTypes ' , new Document ([
2318- '$id ' => ID ::custom ('doc4 ' ),
2319- '$permissions ' => [
2320- Permission::read (Role::any ()),
2321- Permission::create (Role::any ()),
2322- Permission::update (Role::any ()),
2323- Permission::delete (Role::any ()),
2324- ],
2325- 'varchar_field ' => \str_repeat ('a ' , 256 ), // Too long for VARCHAR(255)
2326- ]));
2327- $ this ->fail ('Failed to throw exception for VARCHAR size violation ' );
2328- } catch (Exception $ e ) {
2329- $ this ->assertInstanceOf (StructureException::class, $ e );
2330- }
2315+ // Test VARCHAR size constraint (should fail) - only for adapters that support attributes
2316+ if ($ database ->getAdapter ()->getSupportForAttributes ()) {
2317+ try {
2318+ $ database ->createDocument ('stringTypes ' , new Document ([
2319+ '$id ' => ID ::custom ('doc4 ' ),
2320+ '$permissions ' => [
2321+ Permission::read (Role::any ()),
2322+ Permission::create (Role::any ()),
2323+ Permission::update (Role::any ()),
2324+ Permission::delete (Role::any ()),
2325+ ],
2326+ 'varchar_field ' => \str_repeat ('a ' , 256 ), // Too long for VARCHAR(255)
2327+ ]));
2328+ $ this ->fail ('Failed to throw exception for VARCHAR size violation ' );
2329+ } catch (Exception $ e ) {
2330+ $ this ->assertInstanceOf (StructureException::class, $ e );
2331+ }
23312332
2332- // Test TEXT size constraint (should fail)
2333- try {
2334- $ database ->createDocument ('stringTypes ' , new Document ([
2335- '$id ' => ID ::custom ('doc5 ' ),
2336- '$permissions ' => [
2337- Permission::read (Role::any ()),
2338- Permission::create (Role::any ()),
2339- Permission::update (Role::any ()),
2340- Permission::delete (Role::any ()),
2341- ],
2342- 'text_field ' => \str_repeat ('a ' , 65536 ), // Too long for TEXT(65535)
2343- ]));
2344- $ this ->fail ('Failed to throw exception for TEXT size violation ' );
2345- } catch (Exception $ e ) {
2346- $ this ->assertInstanceOf (StructureException::class, $ e );
2333+ // Test TEXT size constraint (should fail)
2334+ try {
2335+ $ database ->createDocument ('stringTypes ' , new Document ([
2336+ '$id ' => ID ::custom ('doc5 ' ),
2337+ '$permissions ' => [
2338+ Permission::read (Role::any ()),
2339+ Permission::create (Role::any ()),
2340+ Permission::update (Role::any ()),
2341+ Permission::delete (Role::any ()),
2342+ ],
2343+ 'text_field ' => \str_repeat ('a ' , 65536 ), // Too long for TEXT(65535)
2344+ ]));
2345+ $ this ->fail ('Failed to throw exception for TEXT size violation ' );
2346+ } catch (Exception $ e ) {
2347+ $ this ->assertInstanceOf (StructureException::class, $ e );
2348+ }
23472349 }
23482350
23492351 // Test querying by VARCHAR field
0 commit comments