Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
300
Merge Requests
300
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
0aec71aa
Commit
0aec71aa
authored
May 09, 2008
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#256001
by bjaspan: pgsql driver does not handle unsigned numeric fields.
parent
f28c0ae5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
includes/database.pgsql.inc
includes/database.pgsql.inc
+28
-5
No files found.
includes/database.pgsql.inc
View file @
0aec71aa
...
...
@@ -597,12 +597,30 @@ function _db_create_field_sql($name, $spec) {
if
(
$spec
[
'type'
]
==
'serial'
)
{
unset
(
$spec
[
'not null'
]);
}
// pgsql does not have unsigned types but supports constraints to
// restricted a signed field to be non-negative (e.g. CHECK (VALUE
// >= 0)). system.module defines {,small,big}int_unsigned as the
// corresponding integer type with this constraint but does not do
// so for serial or numeric types. It probably would have been
// cleaner to unify unsigned handling but, for now, we use the
// *int_unsigned types for int and otherwise apply a column
// constraint explicitly.
if
(
!
empty
(
$spec
[
'unsigned'
]))
{
if
(
$spec
[
'type'
]
==
'serial'
)
{
$sql
.
=
" CHECK (
$name
>= 0)"
;
}
else
{
$sql
.
=
'_unsigned'
;
switch
(
$spec
[
'type'
])
{
case
'int'
:
$sql
.
=
'_unsigned'
;
break
;
case
'serial'
:
case
'float'
:
$sql
.
=
" CHECK (
$name
>= 0)"
;
break
;
case
'numeric'
:
// handled below
break
;
default
:
// unsigned is not supported on other column types
break
;
}
}
...
...
@@ -613,6 +631,11 @@ function _db_create_field_sql($name, $spec) {
$sql
.
=
'('
.
$spec
[
'precision'
]
.
', '
.
$spec
[
'scale'
]
.
')'
;
}
// For numeric columns this has to come after (precision,scale).
if
(
$spec
[
'type'
]
==
'numeric'
&&
!
empty
(
$spec
[
'unsigned'
]))
{
$sql
.
=
" CHECK (
$name
>= 0)"
;
}
if
(
isset
(
$spec
[
'not null'
])
&&
$spec
[
'not null'
])
{
$sql
.
=
' NOT NULL'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment