Skip to content

Commit

Permalink
global: fix models for PostgreSQL compatibility
Browse files Browse the repository at this point in the history
* BETTER Supports database creation on PostgreSQL server.

* COMPATIBILITY Enables 'sql_mode' as 'ansi_quotes' for quotes
  compatibility for MySQL.

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
  • Loading branch information
Leonardo Rossi committed May 5, 2015
1 parent aae059f commit 7974188
Show file tree
Hide file tree
Showing 54 changed files with 1,542 additions and 1,109 deletions.
8 changes: 5 additions & 3 deletions invenio/ext/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

"""Initialization and configuration for `flask_sqlalchemy`."""

import sqlalchemy

from flask_registry import ModuleAutoDiscoveryRegistry, RegistryProxy

from flask_sqlalchemy import SQLAlchemy as FlaskSQLAlchemy

import sqlalchemy

from invenio.ext.sqlalchemy.types import LegacyBigInteger, LegacyInteger, \
LegacyMediumInteger, LegacySmallInteger, LegacyTinyInteger

Expand Down Expand Up @@ -100,6 +100,7 @@ def update_mutable_dict(self, *args, **kwargs):
obj.MutableDict = MutableDict


# TODO check if we can comment this without problems
# @compiles(types.Text, 'postgresql')
# @compiles(sqlalchemy.dialects.postgresql.TEXT, 'postgresql')
# def compile_text(element, compiler, **kw):
Expand Down Expand Up @@ -141,7 +142,8 @@ def init_app(self, app):
mysql_parameters = {'keep_existing': True,
'extend_existing': False,
'mysql_engine': 'MyISAM',
'mysql_charset': 'utf8'}
'mysql_charset': 'utf8',
'sql_mode': 'ansi_quotes'}

original_table = self.Table

Expand Down
6 changes: 4 additions & 2 deletions invenio/legacy/batchuploader/engine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2010, 2011, 2012, 2013, 2014 CERN.
# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -29,7 +29,7 @@
import tempfile
import re

from invenio.legacy.dbquery import run_sql, Error
from invenio.legacy.dbquery import run_sql
from invenio.modules.access.engine import acc_authorize_action
from invenio.legacy.webuser import collect_user_info, page_not_authorized
from invenio.config import CFG_BINDIR, CFG_TMPSHAREDDIR, CFG_LOGDIR, \
Expand Down Expand Up @@ -59,6 +59,8 @@
except ImportError:
from StringIO import StringIO

from sqlalchemy.exc import SQLAlchemyError as Error

PERMITTED_MODES = ['-i', '-r', '-c', '-a', '-ir',
'--insert', '--replace', '--correct', '--append']

Expand Down
3 changes: 2 additions & 1 deletion invenio/legacy/bibdocfile/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
# pylint: enable=W0622

from invenio.utils.shell import escape_shell_arg, run_shell_command
from invenio.legacy.dbquery import run_sql, DatabaseError
from invenio.legacy.dbquery import run_sql
from invenio.ext.logging import register_exception
from invenio.legacy.bibrecord import record_get_field_instances, \
field_get_subfield_values, field_get_subfield_instances, \
Expand Down Expand Up @@ -127,6 +127,7 @@

import invenio.legacy.template

from sqlalchemy.exc import DatabaseError

def _plugin_bldr(plugin_code):
"""Preparing the plugin dictionary structure."""
Expand Down
8 changes: 6 additions & 2 deletions invenio/legacy/bibdocfile/fulltext_files_migration_kit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Invenio.
# Copyright (C) 2007, 2008, 2010, 2011 CERN.
# Copyright (C) 2007, 2008, 2010, 2011, 2105 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -28,10 +28,14 @@
from intbitset import intbitset
from invenio.utils.text import wrap_text_in_a_box
from invenio.config import CFG_LOGDIR, CFG_SITE_SUPPORT_EMAIL
from invenio.legacy.dbquery import run_sql, OperationalError
from invenio.legacy.dbquery import run_sql
from invenio.legacy.bibdocfile.api import BibRecDocs, InvenioBibDocFileError

from datetime import datetime

from sqlalchemy.exc import OperationalError


def retrieve_fulltext_recids():
"""Returns the list of all the recid number linked with at least a fulltext
file."""
Expand Down
6 changes: 4 additions & 2 deletions invenio/legacy/bibdocfile/icon_migration_kit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Invenio.
# Copyright (C) 2010, 2011 CERN.
# Copyright (C) 2010, 2011, 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -29,14 +29,16 @@

from invenio.utils.text import wrap_text_in_a_box, wait_for_user
from invenio.legacy.bibsched.bibtask import check_running_process_user
from invenio.legacy.dbquery import run_sql, OperationalError
from invenio.legacy.dbquery import run_sql
from invenio.legacy.bibdocfile.api import BibDoc
from invenio.config import CFG_LOGDIR, CFG_SITE_SUPPORT_EMAIL
from invenio.legacy.bibdocfile.cli import cli_fix_marc
from invenio.ext.logging import register_exception
from intbitset import intbitset
from invenio.legacy.search_engine import record_exists

from sqlalchemy.exc import OperationalError


def retrieve_bibdoc_bibdoc():
return run_sql('SELECT id_bibdoc1, id_bibdoc2 from bibdoc_bibdoc')
Expand Down
Loading

0 comments on commit 7974188

Please sign in to comment.