-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PDO_Firebird: Supported Firebird 4.0 datatypes #14897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
950de97
PDO_Firebird: Supported Firebird 4.0 datatypes
sim1984 546af78
tab indent
sim1984 af79543
add EMPTY_SWITCH_DEFAULT_CASE()
sim1984 a70cf1b
Merge branch 'php:master' into master
sim1984 0e056cb
skip if firebird api version < 40
sim1984 841a1e5
Merge branch 'php:master' into master
sim1984 4b71218
usage Pdo\Firebird::getApiVersion() in tests
sim1984 af31c84
Tests fixed.
sim1984 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
PDO_Firebird: Supported Firebird 4.0 datatypes | ||
--EXTENSIONS-- | ||
pdo_firebird | ||
--SKIPIF-- | ||
<?php require('skipif.inc'); | ||
if (Pdo\Firebird::getApiVersion() < 40) { | ||
die('skip: Firebird API version must be greater than or equal to 40'); | ||
} | ||
?> | ||
--XLEAK-- | ||
A bug in firebird causes a memory leak when calling `isc_attach_database()`. | ||
See https://github.com/FirebirdSQL/firebird/issues/7849 | ||
--FILE-- | ||
<?php | ||
require 'testdb.inc'; | ||
|
||
$sql = <<<'SQL' | ||
SELECT | ||
CAST(15 AS BIGINT) AS i64, | ||
CAST(15 AS INT128) AS i128, | ||
123.97 AS N, | ||
CAST(123.97 AS NUMERIC(38,2)) AS N2, | ||
CAST('2024-05-04 12:59:34.239' AS TIMESTAMP) AS TS, | ||
CAST('2024-05-04 12:59:34.239 Europe/Moscow' AS TIMESTAMP WITH TIME ZONE) AS TS_TZ, | ||
CAST('12:59:34.239' AS TIME) AS T, | ||
CAST('12:59:34.239 Europe/Moscow' AS TIME WITH TIME ZONE) AS T_TZ, | ||
CAST(1.128 AS DECFLOAT(16)) AS df16, | ||
CAST(1.128 AS DECFLOAT(34)) AS df34 | ||
FROM RDB$DATABASE | ||
SQL; | ||
|
||
$dbh = getDbConnection(); | ||
|
||
$stmt = $dbh->prepare($sql); | ||
$stmt->execute(); | ||
$data = $stmt->fetch(\PDO::FETCH_ASSOC); | ||
$stmt->closeCursor(); | ||
$str = json_encode($data, JSON_PRETTY_PRINT); | ||
echo $str; | ||
echo "\ndone\n"; | ||
?> | ||
--EXPECT-- | ||
{ | ||
"I64": 15, | ||
"I128": "15", | ||
"N": "123.97", | ||
"N2": "123.97", | ||
"TS": "2024-05-04 12:59:34", | ||
"TS_TZ": "2024-05-04 12:59:34.2390 Europe\/Moscow", | ||
"T": "12:59:34", | ||
"T_TZ": "12:59:34.2390 Europe\/Moscow", | ||
"DF16": "1.128", | ||
"DF34": "1.128" | ||
} | ||
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--TEST-- | ||
PDO_Firebird: Supported Firebird 4.0 datatypes (parameters) | ||
--EXTENSIONS-- | ||
pdo_firebird | ||
--SKIPIF-- | ||
<?php require('skipif.inc'); | ||
if (Pdo\Firebird::getApiVersion() < 40) { | ||
die('skip: Firebird API version must be greater than or equal to 40'); | ||
} | ||
?> | ||
--XLEAK-- | ||
A bug in firebird causes a memory leak when calling `isc_attach_database()`. | ||
See https://github.com/FirebirdSQL/firebird/issues/7849 | ||
--FILE-- | ||
<?php | ||
require 'testdb.inc'; | ||
|
||
$sql = <<<'SQL' | ||
SELECT | ||
CAST(? AS INT128) AS i128, | ||
CAST(? AS NUMERIC(18,2)) AS N1, | ||
CAST(? AS NUMERIC(38,2)) AS N2, | ||
CAST(? AS TIMESTAMP WITH TIME ZONE) AS TS_TZ, | ||
CAST(? AS TIME WITH TIME ZONE) AS T_TZ, | ||
CAST(? AS DECFLOAT(16)) AS df16, | ||
CAST(? AS DECFLOAT(34)) AS df34 | ||
FROM RDB$DATABASE | ||
SQL; | ||
|
||
$dbh = getDbConnection(); | ||
|
||
$stmt = $dbh->prepare($sql); | ||
$stmt->execute([12, 12.34, 12.34, '2024-05-04 12:59:34.239 Europe/Moscow', '12:59 Europe/Moscow', 12.34, 12.34]); | ||
$data = $stmt->fetch(\PDO::FETCH_ASSOC); | ||
$stmt->closeCursor(); | ||
$str = json_encode($data, JSON_PRETTY_PRINT); | ||
echo $str; | ||
echo "\ndone\n"; | ||
?> | ||
--EXPECT-- | ||
{ | ||
"I128": "12", | ||
"N1": "12.34", | ||
"N2": "12.34", | ||
"TS_TZ": "2024-05-04 12:59:34.2390 Europe\/Moscow", | ||
"T_TZ": "12:59:00.0000 Europe\/Moscow", | ||
"DF16": "12.34", | ||
"DF34": "12.34" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my environment, the date format is probably different than yours.
I thought about how to specify the format, but I don't want to do that yet because I think it would be quite complicated.
Therefore, could you please change your test expectations to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done