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] Manager defined in migration is not the clickhouse manager #117

Open
mhaVC opened this issue Jan 30, 2025 · 1 comment
Open

[BUG] Manager defined in migration is not the clickhouse manager #117

mhaVC opened this issue Jan 30, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mhaVC
Copy link

mhaVC commented Jan 30, 2025

Describe the bug
The migration for a new clickhouse model defines the objects manager as the default django manager rather than the ClickhouseManager used in the base ClickhouseModel class.
Accessing the manager in code does return the correct manager ie:

>> DummyModel.objects.__class__
clickhouse_backend.models.base.ClickhouseManager

To Reproduce
The model class:

class DummyModel(models.ClickhouseModel):
    url = models.StringField()

The migration:

# Generated by Django 5.1.2 on 2025-01-30 16:47

import clickhouse_backend.models
import django.db.models.manager
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("dummy_app", "0001_initial_migration"),
    ]

    operations = [
        migrations.CreateModel(
            name="DummyModel",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("url", clickhouse_backend.models.StringField()),
            ],
            options={
                "abstract": False,
                "base_manager_name": "_overwrite_base_manager",
            },
            managers=[
                ("objects", django.db.models.manager.Manager()),
                ("_overwrite_base_manager", django.db.models.manager.Manager()),
            ],
        ),
    ]

Expected behavior
I'd have expected the managers definition in the migration to use the ClickhouseManager class.

Versions

  • ClickHouse server version. Version can be obtained by running SELECT version() query.
    • 24.8
  • Python version.
    • 3.10.14
  • Clickhouse-driver version.
    • 0.2.9
  • Django version.
    • 5.1.2
  • Django clickhouse backend version.
    • 1.3.1
@mhaVC mhaVC added the bug Something isn't working label Jan 30, 2025
@mhaVC mhaVC changed the title [BUG] Manager defined in migration does not use the clickhouse manager [BUG] Manager defined in migration is not the clickhouse manager Jan 30, 2025
@mhaVC
Copy link
Author

mhaVC commented Jan 30, 2025

Is this behavior because django doesn't utilize custom managers in migrations?
Apologies if that is the case and I misunderstood this behavior as a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants