ocsqliteplatform.php 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\DB;
  9. class OCSqlitePlatform extends \Doctrine\DBAL\Platforms\SqlitePlatform {
  10. /**
  11. * {@inheritDoc}
  12. */
  13. public function getColumnDeclarationSQL($name, array $field) {
  14. $def = parent::getColumnDeclarationSQL($name, $field);
  15. if (!empty($field['autoincrement'])) {
  16. $def .= ' PRIMARY KEY AUTOINCREMENT';
  17. }
  18. return $def;
  19. }
  20. /**
  21. * {@inheritDoc}
  22. */
  23. protected function _getCreateTableSQL($name, array $columns, array $options = array()){
  24. // if auto increment is set the column is already defined as primary key
  25. foreach ($columns as $column) {
  26. if (!empty($column['autoincrement'])) {
  27. $options['primary'] = null;
  28. }
  29. }
  30. return parent::_getCreateTableSQL($name, $columns, $options);
  31. }
  32. }