File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ abstract class Expression implements Expressionable, \ArrayAccess
24
24
{
25
25
use DiContainerTrait;
26
26
27
+ private static ?SqlFormatter $ debugFormatter = null ;
28
+
27
29
/** "[]" in template, escape as parameter */
28
30
protected const ESCAPE_PARAM = 'param ' ;
29
31
/** "{}" in template, escape as identifier */
@@ -434,11 +436,14 @@ function ($matches) use ($params, &$i) {
434
436
return $ k ;
435
437
}, $ sql );
436
438
437
- $ sqlFormatter = new SqlFormatter (new NullHighlighter ());
438
- $ sql = $ sqlFormatter ->format ($ sql );
439
+ if (self ::$ debugFormatter === null ) {
440
+ self ::$ debugFormatter = new SqlFormatter (new NullHighlighter ());
441
+ }
442
+
443
+ $ sql = self ::$ debugFormatter ->format ($ sql );
439
444
440
445
// fix string literal tokenize 2/2
441
- $ sql = str_replace (array_keys ($ origStringTokens ), $ origStringTokens , $ sqlFormatter -> format ( $ sql) );
446
+ $ sql = str_replace (array_keys ($ origStringTokens ), $ origStringTokens , $ sql );
442
447
}
443
448
444
449
return $ sql ;
Original file line number Diff line number Diff line change @@ -426,12 +426,14 @@ protected function fixTableNameForListMethod(string $tableName): string
426
426
427
427
public function introspectTableToModel (string $ tableName ): Model
428
428
{
429
- $ columns = $ this ->createSchemaManager ()->listTableColumns ($ this ->fixTableNameForListMethod ($ tableName ));
429
+ $ schemaManager = $ this ->createSchemaManager ();
430
+
431
+ $ columns = $ schemaManager ->listTableColumns ($ this ->fixTableNameForListMethod ($ tableName ));
430
432
if ($ columns === []) {
431
433
$ this ->assertTableExists ($ tableName );
432
434
}
433
435
434
- $ indexes = $ this -> createSchemaManager () ->listTableIndexes ($ this ->fixTableNameForListMethod ($ tableName ));
436
+ $ indexes = $ schemaManager ->listTableIndexes ($ this ->fixTableNameForListMethod ($ tableName ));
435
437
$ primaryIndexes = array_filter ($ indexes , static fn ($ v ) => $ v ->isPrimary () && count ($ v ->getColumns ()) === 1 );
436
438
if (count ($ primaryIndexes ) !== 1 ) {
437
439
throw (new Exception ('Table must contain exactly one primary key ' ))
You can’t perform that action at this time.
0 commit comments