jenkins-bot has submitted this change and it was merged.
Change subject: Some refactoring in ExtendedMySQLAbstraction
......................................................................
Some refactoring in ExtendedMySQLAbstraction
Change-Id: I04abb519f2a51888af74a352ea1c8476e3a68b23
---
M src/MWDB/ExtendedMySQLAbstraction.php
1 file changed, 29 insertions(+), 5 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/MWDB/ExtendedMySQLAbstraction.php
b/src/MWDB/ExtendedMySQLAbstraction.php
index 80e9e36..a9040e2 100644
--- a/src/MWDB/ExtendedMySQLAbstraction.php
+++ b/src/MWDB/ExtendedMySQLAbstraction.php
@@ -73,15 +73,28 @@
protected function getFieldSQL( FieldDefinition $field ) {
$sql = $this->getFieldType( $field->getType() );
- if ( $field->getDefault() !== null ) {
- $sql .= ' DEFAULT ' . $this->getDB()->addQuotes(
$field->getDefault() );
- }
+ $sql .= ' ' . $this->getDefault( $field->getDefault() );
+
+ $sql .= ' ' . $this->getNull( $field->allowsNull() );
+
+ if($field->getIndex()==FieldDefinition::INDEX_PRIMARY &&
$field->getName()!=='id') {q($field);}
+ $sql .= ' ' . $this->getIndexString( $field->getIndex() );
// TODO: add all field stuff relevant here
- $sql .= $field->allowsNull() ? ' NULL' : ' NOT NULL';
-
return $sql;
+ }
+
+ protected function getDefault( $default ) {
+ if ( $default !== null ) {
+ return 'DEFAULT ' . $this->getDB()->addQuotes( $default
);
+ }
+
+ return '';
+ }
+
+ protected function getNull( $allowsNull ) {
+ return $allowsNull ? 'NULL' : 'NOT NULL';
}
/**
@@ -107,4 +120,15 @@
}
}
+ protected function getIndexString( $indexType ) {
+ switch ( $indexType ) {
+ case FieldDefinition::INDEX_PRIMARY:
+ return 'PRIMARY KEY AUTO_INCREMENT';
+ }
+
+ // TODO: handle other index types
+
+ return '';
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/75852
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I04abb519f2a51888af74a352ea1c8476e3a68b23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits