Skip to content

Commit 4894fa1

Browse files
authored
Merge pull request #43 from afgloeden/master
Problem with constraint length of the primary key fixed
2 parents 0336153 + cd8c377 commit 4894fa1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Database/Schema/SybaseGrammar.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SybaseGrammar extends Grammar {
3636
*/
3737
public function compileTableExists()
3838
{
39-
return "SELECT * FROM sysobjects WHERE type = 'U' AND name = '?'";
39+
return "SELECT * FROM sysobjects WHERE type = 'U' AND name = ?";
4040
}
4141

4242
/**
@@ -106,9 +106,16 @@ public function compilePrimary(Blueprint $blueprint, Fluent $command)
106106

107107
$table = $this->wrapTable($blueprint);
108108

109+
// Verify if constraint length is lower to 30 characters.
110+
if (strlen($command->index) > 30) {
111+
$constraint = substr($command->index, 0, 30);
112+
} else {
113+
$constraint = $command->index;
114+
}
115+
109116
return "
110117
ALTER TABLE {$table}
111-
ADD CONSTRAINT {$command->index}
118+
ADD CONSTRAINT {$constraint}
112119
PRIMARY KEY ({$columns})";
113120
}
114121

0 commit comments

Comments
 (0)