maxirobaina / django-firebird

Firebird SQL backend for Django web framework
BSD 3-Clause "New" or "Revised" License
67 stars 47 forks source link

Django 2.x support #80

Closed betonetotbo closed 4 years ago

betonetotbo commented 6 years ago

Please support Django 2.x.

After removing the getLogger import from schema.py I'm trying it but getting:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "D:\dev\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 347, in execute
    django.setup()
  File "D:\dev\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "D:\dev\Python\Python36-32\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\dev\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "D:\Dev\python\ws\django-hello\mysite\polls\models.py", line 4, in <module>
    class Usuario(models.Model):
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 114, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 315, in add_to_class
    value.contribute_to_class(cls, name)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\models\options.py", line 205, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\utils.py", line 203, in __getitem__
    conn = backend.DatabaseWrapper(db, alias)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\backends\firebird\base.py", line 103, in __init__
    super(DatabaseWrapper, self).__init__(*args, **kwargs)
  File "D:\dev\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 101, in __init__
    self.client = self.client_class(self)
TypeError: 'NoneType' object is not callable
cashaev commented 6 years ago

Hi, @betonetotbo, @maxirobaina!

I urgently needed support for Firebird in Django 2.0.3 and came across same issues. And I managed to solve it. Please do it venv, under your own responsibility. So far it works for me. Please let me know if it worked for you!

Here is what I did:

  1. Firebird/base.py
    • added following code to def init() of DatabaseWrapper(BaseDatabaseWrapper) BEFORE super(...).

self.client_class = DatabaseClient self.creation_class = DatabaseCreation self.features_class = DatabaseFeatures self.introspection_class = DatabaseIntrospection self.ops_class = DatabaseOperations self.validation_class = DatabaseValidation

  1. Firebird/compiler.py line 25, removed 'subquery=subuquery' positional argument for as_sql method : sql, params = super(SQLCompiler, self).as_sql(with_limits=False, with_col_aliases=with_col_aliases)

  2. Firebird/schema.py lines 10, 13, commented out logger imports: #from django.utils.log import getLogger #logger = getLogger('django.db.backends.schema')

  3. Firebird/operations.py substitute the line 205 value = utils.typecast_decimal(val) with the following code:

if val is None or val == '': val = None else: val = decimal.Decimal(val)

cashaev commented 6 years ago

About my previous comment: turns out it it fixes only some issues. Afterwards it is not possible to make complicated queries. Unfortunately I do not have knowledge to dig further in

maxirobaina commented 6 years ago

Hi @cashaev

Can you provide me some examples of that complicated queries that you want to do an what problems do you have?

Regards.

thesunlover commented 5 years ago

C:\work\django1\lib\site-packages\firebird\introspection.py

try:
    from django.utils.deprecation import RemovedInDjango21Warning
except ImportError:
    RemovedInDjango21Warning = None

and under that:

    if RemovedInDjango21Warning:
      def get_indexes(self, cursor, table_name):

it will work on py3 + django 2.2

mariuz commented 4 years ago

Some of the django 2.2 issues are fixed by #111

I guess this can be closed