File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ public function compileDrop(SqlEntity $entity): string
43
43
return $ this ->clean ($ statement );
44
44
}
45
45
46
+ /** Determine if the grammar supports the entity. */
47
+ public function supportsEntity (SqlEntity $ entity ): bool
48
+ {
49
+ return match (true ) {
50
+ $ entity instanceof View => true ,
51
+ default => false ,
52
+ };
53
+ }
46
54
abstract protected function compileViewCreate (View $ entity ): string ;
47
55
48
56
protected function compileViewDrop (View $ entity ): string
Original file line number Diff line number Diff line change @@ -27,16 +27,16 @@ class SqlEntityManager
27
27
{
28
28
use SortsTopologically;
29
29
30
+ /** @var TEntities */
31
+ public Collection $ entities ;
32
+
30
33
/**
31
34
* The active connection instances.
32
35
*
33
36
* @var array<string, Connection>
34
37
*/
35
38
protected array $ connections = [];
36
39
37
- /** @var TEntities */
38
- public Collection $ entities ;
39
-
40
40
/**
41
41
* The active grammar instances.
42
42
*
@@ -112,6 +112,18 @@ public function create(SqlEntity|string $entity): void
112
112
113
113
$ grammar = $ this ->grammar ($ connection );
114
114
115
+ if (! $ grammar ->supportsEntity ($ entity )) {
116
+ logger ()->warning (
117
+ sprintf (
118
+ 'Skipping creation of entity [%s]: not supported by %s. ' ,
119
+ $ entity ::class,
120
+ $ grammar ::class,
121
+ ),
122
+ );
123
+
124
+ return ;
125
+ }
126
+
115
127
$ connection ->statement ($ grammar ->compileCreate ($ entity ));
116
128
$ entity ->created ($ connection );
117
129
$ this ->states [$ entity ::class] = 'created ' ;
@@ -141,6 +153,18 @@ public function drop(SqlEntity|string $entity): void
141
153
142
154
$ grammar = $ this ->grammar ($ connection );
143
155
156
+ if (! $ grammar ->supportsEntity ($ entity )) {
157
+ logger ()->warning (
158
+ sprintf (
159
+ 'Skipping dropping of entity [%s]: not supported by %s. ' ,
160
+ $ entity ::class,
161
+ $ grammar ::class,
162
+ ),
163
+ );
164
+
165
+ return ;
166
+ }
167
+
144
168
$ connection ->statement ($ grammar ->compileDrop ($ entity ));
145
169
$ entity ->dropped ($ connection );
146
170
$ this ->states [$ entity ::class] = 'dropped ' ;
You can’t perform that action at this time.
0 commit comments