maxtepkeev / architect

A set of tools which enhances ORMs written in Python with more features
Other
391 stars 57 forks source link

Unable to initialize architect using Django #2

Closed faxioman closed 9 years ago

faxioman commented 9 years ago

Hi. I'm not able to initialize architect using Django I'm trying using:

architect partition --module mdata.models

where mdata is my app and models the module with my partitioned model. I'm using virtualenv and my current path is where "mdata" exists.

faxioman commented 9 years ago

Anyway, setting the PYTHONPATH to my current folder, works.

maxtepkeev commented 9 years ago

Hi!

If I understood you correctly, architect was unable to find your models and you managed to get it working after modifying PYTHONPATH, right ?

faxioman commented 9 years ago

Yes, correct.

nickspring commented 9 years ago

same problem

budlight commented 9 years ago

I had this same problem, also might need a documentation warning for django users that you can't use foreign keys like

user = models.ForeignKey(
        'account.Account', blank=True, null=True,
        on_delete=models.SET_NULL)

instead use:

from account.models import Account
user = models.ForeignKey(
        Account, blank=True, null=True,
        on_delete=models.SET_NULL)
maxtepkeev commented 9 years ago

Initializing problem with Django will be fixed in the next version, thank you all guys for reporting this.

@budlight Working with foreign keys currently is not implemented in the way it should be. This is a work in progress and will be released as soon as it is finished. There are also a lot more stuff to do to make the library fully compatible and correctly working with all the database features. I'm considering to create a FAQ, TODO and so on, to make it more transparent and understandable for other users and contributors to understand what's going on and what needs to be implemented.

Anyway I highly appreciate any reports about all the problems you have or any other suggestions.

budlight commented 9 years ago

I don't have your test suite setup not sure all the ins and outs of it but something like add in

from django.db import transaction

then

    def test_range_atomic(self):
        with transaction.atomic():
            object1 = RangeDateYear.objects.create(name='foo', created=datetime.datetime(2014, 4, 15, 18, 44, 23))
        object2 = RangeDateYear.objects.raw('SELECT * FROM test_rangedateyear_y2014 WHERE id = %s', [object1.id])[0]

        self.assertTrue(object1.name, object2.name)

should trigger an exception, not the best test, but like I said haven't tried out your test suite

gotlium commented 9 years ago
ALTER TABLE dbmail_maillog PARTITION BY RANGE (TO_DAYS(created))(
            PARTITION dbmail_maillog_y2014m12 VALUES LESS THAN (0)
);

MSG: Cannot delete or update a parent row: a foreign key constraint fails

MySQL does not support foreign keys on partitioned tables.

Foreign keys not supported for partitioned InnoDB tables. Partitioned tables using the InnoDB storage engine do not support foreign keys. More specifically, this means that the following two statements are true:

  1. No definition of an InnoDB table employing user-defined partitioning may contain foreign key references; no InnoDB table whose definition contains foreign key references may be partitioned.
  2. No InnoDB table definition may contain a foreign key reference to a user-partitioned table; no InnoDB table with user-defined partitioning may contain columns referenced by foreign keys.
pajooh commented 9 years ago

@maxtepkeev could you tag a new version (0.2.1?) containing the fix of this bug please? where using pip, it's better to tag frequently to keep everyone up to date

maxtepkeev commented 9 years ago

@pajooh Yeah, I know. The problem is that there are several other important bugs that should be fixed before the next release will be possible. I didn't have a time for this project until now, now I'm in the process of rewriting some parts of it and fixing the bugs, so expect a new release in the next few weeks.

maxtepkeev commented 9 years ago

Fixed in v0.3.0. Please see docs, because Architect was almost completely rewritten.

@gotlium I didn't completely get what your comment was about. If it is still relevant, please open a new issue with detailed description of the problem.