33namespace Uepg \LaravelSybase \Database \Schema ;
44
55use Illuminate \Database \Schema \Grammars \Grammar as IlluminateGrammar ;
6+ use Illuminate \Database \Schema \Blueprint ;
67use Illuminate \Support \Fluent ;
78
89class Grammar extends IlluminateGrammar
910{
11+ /**
12+ * The possible column modifiers.
13+ *
14+ * @var array
15+ */
1016 /**
1117 * The possible column modifiers.
1218 *
1319 * @var array
1420 */
1521 protected $ modifiers = [
16- 'Increment ' , 'Nullable ' , 'Default ' ,
22+ 'Increment ' ,
23+ 'Nullable ' ,
24+ 'Default ' ,
1725 ];
1826
1927 /**
@@ -22,27 +30,19 @@ class Grammar extends IlluminateGrammar
2230 * @var array
2331 */
2432 protected array $ serials = [
25- 'bigInteger ' , 'integer ' , 'numeric ' ,
33+ 'bigInteger ' ,
34+ 'integer ' ,
35+ 'numeric ' ,
2636 ];
2737
2838 /**
2939 * Compile the query to determine if a table exists.
30- * @param string|null $schema
31- * @param string $table
40+ *
3241 * @return string
3342 */
34- public function compileTableExists ($ schema , $ table )
43+ public function compileTableExists ($ schema ,$ table )
3544 {
36- return sprintf ('
37- SELECT
38- COUNT(*) AS [exists]
39- FROM
40- sysobjects
41- WHERE
42- type = \'U \'
43- AND
44- name = \'%s \';
45- ' , $ schema ? $ schema .'. ' .$ table : $ table );
45+ return "SELECT id FROM sysobjects WHERE type = 'U' AND name = ' $ table' " ;
4646 }
4747
4848 /**
@@ -105,7 +105,7 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
105105 * @return string
106106 * Functions do compile the columns of a given table
107107 */
108- public function compileColumns ($ table )
108+ public function compileColumns ($ schema , $ table )
109109 {
110110 return "SELECT
111111 col.name,
@@ -141,7 +141,7 @@ public function compileColumns($table)
141141 * @return string
142142 * Functions that return the indexes of a given table
143143 */
144- public function compileIndexes ($ table )
144+ public function compileIndexes ($ schema , $ table )
145145 {
146146 return "SELECT
147147 DISTINCT i.name,
@@ -239,8 +239,6 @@ public function compileIndex(Blueprint $blueprint, Fluent $command)
239239 /**
240240 * Compile a drop table command.
241241 *
242- * @param Blueprint $blueprint
243- * @param Fluent $command
244242 * @return string
245243 */
246244 public function compileDrop (Blueprint $ blueprint , Fluent $ command )
@@ -251,8 +249,6 @@ public function compileDrop(Blueprint $blueprint, Fluent $command)
251249 /**
252250 * Compile a drop table (if exists) command.
253251 *
254- * @param Blueprint $blueprint
255- * @param Fluent $command
256252 * @return string
257253 */
258254 public function compileDropIfExists (Blueprint $ blueprint , Fluent $ command )
@@ -283,7 +279,8 @@ public function compileDropColumn(Blueprint $blueprint, Fluent $command)
283279
284280 $ table = $ this ->wrapTable ($ blueprint );
285281
286- return 'ALTER TABLE ' .$ table .' DROP COLUMN ' .implode (', ' , $ columns );
282+ return 'ALTER TABLE ' .$ table .
283+ ' DROP COLUMN ' .implode (', ' , $ columns );
287284 }
288285
289286 /**
@@ -331,14 +328,15 @@ public function compileDropIndex(Blueprint $blueprint, Fluent $command)
331328 /**
332329 * Compile a drop foreign key command.
333330 *
334- * @param Blueprint $blueprint
335- * @param Fluent $command
331+ * @param \Illuminate\Database\Schema\ Blueprint $blueprint
332+ * @param \Illuminate\Support\ Fluent $command
336333 * @return string
337334 */
338- public function compileDropForeign (Blueprint $ blueprint , Fluent $ command )
335+ public function compileDropForeign (Blueprint $ blueprint , Fluent $ command ): string
339336 {
340337 $ table = $ this ->wrapTable ($ blueprint );
341338
339+ // O SQL que você postou antes:
342340 return "ALTER TABLE {$ table } DROP CONSTRAINT {$ command ->index }" ;
343341 }
344342
@@ -665,7 +663,7 @@ protected function modifyNullable(Blueprint $blueprint, Fluent $column)
665663 */
666664 protected function modifyDefault (Blueprint $ blueprint , Fluent $ column )
667665 {
668- if (!is_null ($ column ->default )) {
666+ if (! is_null ($ column ->default )) {
669667 return ' default ' .$ this ->getDefaultValue ($ column ->default );
670668 }
671669 }
@@ -679,7 +677,10 @@ protected function modifyDefault(Blueprint $blueprint, Fluent $column)
679677 */
680678 protected function modifyIncrement (Blueprint $ blueprint , Fluent $ column )
681679 {
682- if (in_array ($ column ->type , $ this ->serials ) && $ column ->autoIncrement ) {
680+ if (
681+ in_array ($ column ->type , $ this ->serials ) &&
682+ $ column ->autoIncrement
683+ ) {
683684 return ' identity primary key ' ;
684685 }
685686 }
0 commit comments