Giter VIP home page Giter VIP logo

Comments (5)

mootensai avatar mootensai commented on June 15, 2024

Could you give me your schema / mysql dump?? I've tried on sakila db and it's fine..

Sorry, I don't really get you issue.. What is the error and what it should be?

I'm currently doing this relation-trait by the way..

from yii2-relation-trait.

lupoalberto avatar lupoalberto commented on June 15, 2024

Sorry, my english is not at best... However as you can see I attached a test database. There are 5 tables:
persons, country, countries, language, languages and several relations. Basically the countries and languages tables are the m:n raltion tables.

Now...everything works fine, as you can see, I created some persons with related data as countries and languages. The problem is, that if I try to update a person and remove for example all the related countries, than try to save it, nothing happens. I mean...everything seems to be ok, no error message, redirecting to the view page, etc. but when I reload the page all the countries are still there. If I remove only one item, everything is fine, the problem occurs only if I remove all the items of one related table.

Also, everything works fine when I remove all the items of both related tables and even if one of the realted tables is already empty. However you can reproduce the issue by creating a person in my attached example. Then relate two countries and two languages. Next, save it. Everything should work. Now try to remove both related countries for example and try to save. As you can see, saving seems to be successfully but the removed countries are still there (no error message).

All the models, controller and views I created with IO Generator of gii

About the "fields" array mentioned in my first post here: in my opinion this should be automatically fixed at the moment when you implement the "composite primary key" as discussed in my other post, so don't care about that.
Thank you for your support and your great work!

test.sql.zip

from yii2-relation-trait.

mootensai avatar mootensai commented on June 15, 2024

Thanks!

from yii2-relation-trait.

lupoalberto avatar lupoalberto commented on June 15, 2024

Hello mootensai

I unfortunately think I found another mistake. In the attached example I have 4 tables: main (the main table), sub1 (first n:m relation), sub2 (second n:m relation), persons (the target table of the n:m relations).
All the models, controller and views I created with IO Generator of gii and leaved them untouched.

Now if you try to go the main view in yii2 everything works fine, as long as I put in values for only one subquery. At the moment I try to put in values for subquery1 and subquery2 it fails with this error message:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 3 column(s)
The SQL being executed was: DELETE FROM sub2 WHERE (mainid=1) AND ((mainid, personsid, somevalue) NOT IN (('1','1'), ('1','2'), ('1','3'), ('1','2','23')))

example.sql.zip

Greez

from yii2-relation-trait.

mootensai avatar mootensai commented on June 15, 2024

What function do you use?
Please create another issue because it seems like another problem

from yii2-relation-trait.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.