Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] NetworkField does not work with MySQL/MariaDB #146

Open
pandafy opened this issue Dec 12, 2022 · 2 comments
Open

[bug] NetworkField does not work with MySQL/MariaDB #146

pandafy opened this issue Dec 12, 2022 · 2 comments

Comments

@pandafy
Copy link
Member

pandafy commented Dec 12, 2022

Running migrations on MySQL (Server version: 8.0.31 MySQL Community Server - GPL) raises following error

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cidr NOT NULL, `description` varchar(100) NOT NULL, `master_subnet_id` char(32) ' at line 1")

The CIDR data type is also not supported on MariaDB.

class NetworkField(models.Field):
empty_strings_allowed = False
description = 'CIDR type network field'
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 43
super().__init__(*args, **kwargs)
def db_type(self, connection):
return 'cidr'

@Manchuker1120
Copy link

I also encountered this problem

@Manchuker1120
Copy link

Manchuker1120 commented Jul 7, 2023

(
'subnet',
models.CharField(
db_index=True,
help_text=(
'Subnet in CIDR notation, eg: "10.0.0.0/24" '
'for IPv4 and "fdb6:21b:a477::9f7/64" for IPv6'
),
max_length=43,
)

I can add openwisp_ipam/migrations/0001_initial.py modified to the above content? If I make changes, I can migrate the database without reporting any errors, but what are the issues if I make the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants