Skip to content

Commit

Permalink
removed useless type juggling
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 26, 2017
1 parent 13bc0e9 commit d46fee7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Database/Drivers/MySqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)

} elseif ($limit !== NULL || $offset) {
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
$sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
$sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : $limit)
. ($offset ? ' OFFSET ' . $offset : '');
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Database/Drivers/OciDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)
} elseif ($offset) {
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
. ($limit !== NULL ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
. ') WHERE "__rnum" > '. (int) $offset;
. ($limit !== NULL ? 'WHERE ROWNUM <= ' . ($offset + $limit) : '')
. ') WHERE "__rnum" > ' . $offset;

} elseif ($limit !== NULL) {
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . $limit;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/OdbcDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)
throw new Nette\InvalidArgumentException('Negative offset or limit.');

} elseif ($limit !== NULL) {
$sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
$sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . $limit, $sql, 1, $count);
if (!$count) {
throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Drivers/PgSqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)
throw new Nette\InvalidArgumentException('Negative offset or limit.');
}
if ($limit !== NULL) {
$sql .= ' LIMIT ' . (int) $limit;
$sql .= ' LIMIT ' . $limit;
}
if ($offset) {
$sql .= ' OFFSET ' . (int) $offset;
$sql .= ' OFFSET ' . $offset;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Database/Drivers/SqliteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)
throw new Nette\InvalidArgumentException('Negative offset or limit.');

} elseif ($limit !== NULL || $offset) {
$sql .= ' LIMIT ' . ($limit === NULL ? '-1' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
$sql .= ' LIMIT ' . ($limit === NULL ? '-1' : $limit)
. ($offset ? ' OFFSET ' . $offset : '');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset)
throw new Nette\NotSupportedException('Offset is not supported by this database.');

} elseif ($limit !== NULL) {
$sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
$sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . $limit, $sql, 1, $count);
if (!$count) {
throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/SqlLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SqlLiteral

public function __construct(string $value, array $parameters = [])
{
$this->value = (string) $value;
$this->value = $value;
$this->parameters = $parameters;
}

Expand Down

0 comments on commit d46fee7

Please sign in to comment.