File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55class MiscellaneousTest extends \PHPUnit \Framework \TestCase
66 {
7- public function testNoStringPrimaryKey () : void
8- {
9- $ customer = new \Tests \App \Record \Customer (1 );
10- $ this ->assertTrue ($ customer ->loaded ());
11- $ this ->expectException (\PHPFUI \ORM \Exception::class);
12- $ customer = new \Tests \App \Record \Customer ('test ' );
13- }
14-
157 public function testRow () : void
168 {
179 $ row = \PHPFUI \ORM ::getRow ('select * from customer ' );
Original file line number Diff line number Diff line change @@ -63,18 +63,28 @@ public function __construct(int|array|null|string $parameter = null)
6363
6464 switch ($ type )
6565 {
66- case 'integer ' :
67- $ type = 'int ' ;
68- // Intentionally fall through
6966 case 'string ' :
7067
71- if (1 == \count (static ::$ primaryKeys ) && $ type == static ::$ fields [static ::$ primaryKeys [0 ]][self ::PHP_TYPE_INDEX ])
68+ if (1 == \count (static ::$ primaryKeys ))
69+ {
70+ $ this ->read ($ parameter );
71+ }
72+ else
73+ {
74+ throw new \PHPFUI \ORM \Exception (static ::class . ' has no string primary key ' );
75+ }
76+
77+ break ;
78+
79+ case 'integer ' :
80+
81+ if (1 == \count (static ::$ primaryKeys ) && 'int ' == static ::$ fields [static ::$ primaryKeys [0 ]][self ::PHP_TYPE_INDEX ])
7282 {
7383 $ this ->read ($ parameter );
7484 }
7585 else
7686 {
77- throw new \PHPFUI \ORM \Exception (static ::class . ' has no ' . $ type . ' primary key ' );
87+ throw new \PHPFUI \ORM \Exception (static ::class . ' does not have an integer primary key ' );
7888 }
7989
8090 break ;
You can’t perform that action at this time.
0 commit comments