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

ignoreUnknownColumns=>true fails on Model::save() #11907

Closed
igorsantos07 opened this issue Jun 18, 2016 · 11 comments
Closed

ignoreUnknownColumns=>true fails on Model::save() #11907

igorsantos07 opened this issue Jun 18, 2016 · 11 comments
Assignees
Labels
stale Stale issue - automatically closed

Comments

@igorsantos07
Copy link
Contributor

igorsantos07 commented Jun 18, 2016

While enabling ignoreUnknownColumns do allow us to not specify repeated column names on columnMaps (as per a comment in another issue, as this is nowhere to be found in the docs), it still triggers Column 'blah' isn't part of the column map. In the stacktrace, it was triggered inside Phalcon\Mvc\Model->_preSave().

This was found under 2.0.11 and then tested under 2.0.13 and 2.1.0 RC1 (7992678), both still displaying this issue.

Sample steps to reproduce:

  1. have a table with a couple of fields, for instance id, name, age
  2. set the model's columnMap to return ['name' => 'fullName']
  3. If you try to run a find() on it or something similar, it will trigger a columnMap error (as the age field is missing in the columnMap definition)
  4. setting \Phalcon\Mvc\Model::setup(['ignoreUnknownColumns' => true]) will clear up the find() error
  5. however, that error will still appear if you try to run save() on the said model
@igorsantos07
Copy link
Contributor Author

I was wondering if I could get someone's attention to this issue? There's 9 months it was opened, and got no reply 🤔

To help figure out what's going on, I tried to reproduce it in a simple project: I forked the sample project Invo, placed it into a dockerized environment with the new Phalcon 3, and created a branch with the problem.

Actually, I couldn't even get ignoreUnknownColumns to work in find() scenarios as state in the initial bug report. To reproduce:

  1. clone the repo (https://github.com/igorsantos07/invo) and checkout the columnmap-issue branch
  2. run docker-compose up -d
  3. run docker-compose logs -f to follow logs and see when the DB will be ready
  4. access http://localhost:8000
  5. an error message will popup and the logs in your terminal will state the id column isn't part of the columnMap, even with ignoreUnknownColumns enabled at Services::initDb(). Adding that line just above the find() command on IndexController::indexAction yields the same error.

@sergeyklay
Copy link
Contributor

I'll take a look as soon as I can.

Thank you for contributing

@Druid33
Copy link

Druid33 commented Sep 7, 2017

I have the same problem on phalcon 3.2.1.
Database i used is oracle 10g

@Jurigag
Copy link
Contributor

Jurigag commented Sep 7, 2017

@Druid33 @igorsantos07 could you try add to php.ini on proper sapi:

phalcon.orm.ignore_unkown_columns = 1

And restart your webserver/php-fpm and check again? This is just a guess.

@igorsantos07
Copy link
Contributor Author

igorsantos07 commented Oct 5, 2017 via email

@Druid33
Copy link

Druid33 commented Oct 11, 2017

@Jurigag

adding phalcon.orm.ignore_unkown_columns = 1 has no effect.

@Jurigag
Copy link
Contributor

Jurigag commented Oct 11, 2017

Your added it to correct sapi and restarted your webserver?

@sergeyklay
Copy link
Contributor

Database i used is oracle 10g

@Druid33 There is any chance to test phalcon.orm.ignore_unkown_columns with MySQL/PostgreSql/SQLite?

@stale
Copy link

stale bot commented Apr 16, 2018

Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues

@stale stale bot added the stale Stale issue - automatically closed label Apr 16, 2018
@pmanup
Copy link

pmanup commented Feb 26, 2019

the problem it's that orm generate metada from database and not from custom model.

if you put one method in yur parent class for all models like this:

use Phalcon\Mvc\Model\MetaData\Strategy\Annotations;

    public function metaData()
    {
        $anotations = new Annotations();
        return $anotations->getMetaData( $this, \Phalcon\DI::getDefault() );
    }

now, metada is generated from your model and you can add columns in your database without touch your model.

@Chealer
Copy link

Chealer commented Jul 22, 2021

I am getting this error with Phalcon\Mvc\Model\Resultset\Simple::toArray() with Phalcon 3.4.5. Is this supposed to be solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issue - automatically closed
Projects
None yet
Development

No branches or pull requests

6 participants