简体   繁体   English

Django 端口从 Postgres 到 MariaDB manage.py 迁移错误 SQL 语法错误 1064

[英]Django Port from Postgres to MariaDB manage.py migrate error SQL Syntax Error 1064

I am porting my Django application from Postgres to MariaDB and receive the following error when doing the migration step:我正在将我的 Django 应用程序从 Postgres 移植到 MariaDB 并在执行迁移步骤时收到以下错误:

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[20] NOT NULL, `last_update` datetime(6) NOT NULL, `commited` bool NOT NULL, ...' at line 1")

All the standard Django tables are created and my first model table is created.创建了所有标准 Django 表,并创建了我的第一个 model 表。 But I never get beyond that step.但我永远不会超越那一步。

My models are all of the following style:我的模型都是以下风格:

class Country(models.Model):
        name = models.CharField(max_length=100, unique=True,
                                help_text=_('This is the full name of the country'),
                                verbose_name=_('Country'),
                                )
        alternate_name = models.CharField(max_length=100, null=True, blank=True,
                                help_text=_('This is the alternate name - often abbreviation - of the country'),
                                verbose_name=_('Country alternate name'),
                                )
        iso_numeric = models.DecimalField(max_digits=3, decimal_places=0,null=True,
                                help_text=_('This is the ISO numeric code of the country'),
                                verbose_name=_('ISO numeric code'),
                                )
        iso_alpha = models.CharField(max_length=3, null=True, blank=True,
                                help_text=_('This is the ISO alpha code of the country'),
                                verbose_name=_('ISO alpha code'),
                                )
        last_update = models.DateTimeField(auto_now_add=True,
                                help_text=_('This is the timestamp of the last update'),
                                verbose_name=_('Timestamp last update'),
                                )
        last_update_id = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL, editable=False,
                                help_text=_('This is the user making last update'),
                                verbose_name=_('User making last update'),
                                )
        committed = models.BooleanField(default=False, editable=False,
                                help_text=
                                _('This field is set to false once record is created until admin has committed it'),
                                verbose_name=_('Committed'),
                                )

I have seen similar issues referring potentially to the DateTime or Boolean fields.我已经看到可能涉及 DateTime 或 Boolean 字段的类似问题。 However even if I comment them out I get the same result.但是,即使我将它们注释掉,我也会得到相同的结果。

MariaDB: MariaDB [(none)]> status MariaDB: MariaDB [(无)]> 状态

mysql Ver 15.1 Distrib 10.4.13-MariaDB, for osx10.15 (x86_64) using readline 5.1 mysql Ver 15.1 Distrib 10.4.13-MariaDB,适用于使用 readline 5.1 的 osx10.15 (x86_64)

I am using mysqlclient 1.4.6.我正在使用 mysqlclient 1.4.6。

Any pointers?任何指针? Thanks, Martin谢谢,马丁

The Django sql produced contains an array.生产的 Django sql 包含一个阵列。 The following model field:以下 model 字段:

alternate_name = models.CharField(max_length=60, blank=True, null=True,
                            help_text=_('This is a list of alternate grape names'),
                            verbose_name=_('Alternate grape names'),
                            )

Resulted in the following sql:导致以下 sql:

`alternate_name` varchar(30)[20] NOT NULL,

I have altered the sql removing the array information and run the queries manually.我已更改 sql 删除数组信息并手动运行查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM