summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-11-15 04:19:33 -0800
committerBart Visscher <bartv@thisnet.nl>2013-11-15 04:19:33 -0800
commit630e46f60a7ac43815d14dd3d224de8ae3038465 (patch)
tree166c1e41ac2ea234ffece0ca431f9bce9e35979a
parent16dce5191751e0e6b394fc5cc58690a77dc82870 (diff)
parent53f17a71d1eedc5a520874b40b51890fa5559d4d (diff)
downloadnextcloud-server-630e46f60a7ac43815d14dd3d224de8ae3038465.tar.gz
nextcloud-server-630e46f60a7ac43815d14dd3d224de8ae3038465.zip
Merge pull request #5789 from ogasser/db_fix_default_for_numeric
DB: Set correct default value for numeric types
-rw-r--r--lib/private/db/mdb2schemareader.php5
-rw-r--r--tests/data/db_structure.xml22
-rw-r--r--tests/data/db_structure2.xml22
3 files changed, 48 insertions, 1 deletions
diff --git a/lib/private/db/mdb2schemareader.php b/lib/private/db/mdb2schemareader.php
index ad4c39a9935..511bd1c90bd 100644
--- a/lib/private/db/mdb2schemareader.php
+++ b/lib/private/db/mdb2schemareader.php
@@ -150,6 +150,9 @@ class MDB2SchemaReader {
case 'timestamp':
$type = 'datetime';
break;
+ case 'numeric':
+ $type = 'decimal';
+ break;
}
break;
case 'length':
@@ -193,7 +196,7 @@ class MDB2SchemaReader {
} else {
$options['default'] = '';
}
- if ($type == 'integer') {
+ if ($type == 'integer' || $type == 'decimal') {
$options['default'] = 0;
} elseif ($type == 'boolean') {
$options['default'] = false;
diff --git a/tests/data/db_structure.xml b/tests/data/db_structure.xml
index 2e83bbb78c7..5f2edbbc516 100644
--- a/tests/data/db_structure.xml
+++ b/tests/data/db_structure.xml
@@ -199,4 +199,26 @@
</declaration>
</table>
+ <table>
+ <name>*dbprefix*decimal</name>
+ <declaration>
+ <field>
+ <name>id</name>
+ <autoincrement>1</autoincrement>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <length>4</length>
+ </field>
+
+ <field>
+ <name>decimaltest</name>
+ <type>decimal</type>
+ <default/>
+ <notnull>true</notnull>
+ <length>15</length>
+ </field>
+ </declaration>
+ </table>
+
</database>
diff --git a/tests/data/db_structure2.xml b/tests/data/db_structure2.xml
index bbfb24985cb..6cd071451df 100644
--- a/tests/data/db_structure2.xml
+++ b/tests/data/db_structure2.xml
@@ -96,4 +96,26 @@
</declaration>
</table>
+ <table>
+ <name>*dbprefix*decimal</name>
+ <declaration>
+ <field>
+ <name>id</name>
+ <autoincrement>1</autoincrement>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <length>4</length>
+ </field>
+
+ <field>
+ <name>decimaltest</name>
+ <type>decimal</type>
+ <default/>
+ <notnull>true</notnull>
+ <length>15</length>
+ </field>
+ </declaration>
+ </table>
+
</database>