ikkez / f3-cortex

A multi-engine ORM / ODM for the PHP Fat-Free Framework
GNU General Public License v3.0
118 stars 22 forks source link

After update, shows up glich #22

Closed jekabsmilbrets closed 8 years ago

jekabsmilbrets commented 8 years ago

After update/fix for #21

I'm having very interesting glich.

I have small script that is "mass-insert" within transaction, before that hotfix for #21 everything worked perfect, but now i get errors: btw all data is inserted with copyfrom($array)

  "errors": {
    "serverError": {
      "status": "Internal Server Error",
      "code": 500,
      "text": "PDOStatement: Unknown column 'industry_code11' in 'field list'",
      "trace": [
        "[lib/base.php:2041] Base->error(500,'PDOStatement: Unknown column 'industry_code11' in 'field list'')",
        "[lib/DB/SQL/Mapper.php:275] DB\\SQL->exec('SELECT `id`,`_product`,`_campaign`,`_demograph`,`rotation_code`,`date`,`duration`,`start_date`,`end_date`,`third_party_included`,(industry_code11) AS `industry_code`,(house_number11) AS `house_number`,(event_number11) AS `event_number` FROM `copyrotation` WHERE id=?',[1=>2],0)",
        "[lib/DB/SQL/Mapper.php:317] DB\\SQL\\Mapper->select('`id`,`_product`,`_campaign`,`_demograph`,`rotation_code`,`date`,`duration`,`start_date`,`end_date`,`third_party_included`,(industry_code11) AS `industry_code`,(house_number11) AS `house_number`,(event_number11) AS `event_number`',['id=?',2],['group'=>NULL,'order'=>NULL,'limit'=>0,'offset'=>0],0)",
        "[lib/DB/Cursor.php:175] DB\\SQL\\Mapper->find(['id=?',2],NULL,0)",
        "[lib/DB/SQL/Mapper.php:430] DB\\Cursor->load(['id=?',2])",
        "[lib/DB/Cortex.php:2037] DB\\SQL\\Mapper->insert()",
        "[lib/DB/Cortex.php:1114] DB\\Cortex->insert()",
        "[app/ControllerTraits/MassInsertTraits.php:16] DB\\Cortex->save()",
        "[app/ControllerTraits/MassInsertTraits.php:28] Controller\\MassInsert->insert_record(ModelCopyRotation::__set_state([]),['_product'=>'1','_campaign'=>'1','_sales_areas'=>'1,2','_demograph'=>'5','rotation_code'=>'rotation_code11','date'=>'2015-12-01','duration'=>'30','start_date'=>'2015-12-01','end_date'=>'2015-12-31','industry_code'=>'industry_code11','house_number'=>'house_number11','event_number'=>'event_number11','third_party_included'=>'1'])",

its intersting as its trying to select actual value as field name, why ?!

ikkez commented 8 years ago

That happens in the underlaying F3 SQL Mapper when you set a value to a fields that is not existing. When you set: $mapper->foo = 'bar' and foo is not existing, the F3 mapper thinks it's a virtual fields, creating a (bar) as foo expression. Maybe the field cache is wrong. try to clear your tmp/ folder or CACHE engine.

jekabsmilbrets commented 8 years ago

cache it was!

jekabsmilbrets commented 8 years ago

something awkward is now happening

here is code, that worked before update: ` $copy_rotation_model = new \Model\CopyRotation();

        $copy_rotation_model->has('_sales_areas', ['_id IN ?', explode(',', $this->INPUT_DATA['_sales_areas'])]);
        // $copy_rotation_model->filter('_sales_areas', ['_id IN ?', explode(',', $this->INPUT_DATA['_sales_areas'])]);
        $copy_rotation_model->has('_product', ['_id = ?', $this->INPUT_DATA['_product']]);
        $copy_rotation_model->has('_time_ranges', ['start_time >= ? AND end_time <= ?', $this->INPUT_DATA['start_time'], $this->INPUT_DATA['end_time']]);

        $query = [
            'start_date >= ? AND end_date <= ?',
            $this->INPUT_DATA['start_date'],
            $this->INPUT_DATA['end_date']
        ];

        $found_copy_rotations = $copy_rotation_model->find($query);

`

But after update this error shows up!

"[lib/base.php:2041] Base->error(500,'PDOStatement: Unknown column 'copyrotation.start_copyrotation.date' in 'where clause'')" "[lib/DB/Cortex.php:780] DB\SQL->exec('SELECT copyrotation.* FROM copyrotation LEFT JOIN _copy_rotations__sales_areas ON copyrotation.id = _copy_rotations__sales_areas._copy_rotations LEFT JOIN salesareas ON _copy_rotations__sales_areas._sales_areas = salesareas.id LEFT JOIN product ON copyrotation._product = product.id WHERE ((copyrotation.start_copyrotation.date >= ? AND copyrotation.end_copyrotation.date <= ?) and (salesareas._copyrotation.id IN (?,?,?))) and (product.id = ?) and (copyrotation.id IN (?,?)) GROUP BY copyrotation.id',[1=>'2015-12-01',2=>'2015-12-31',3=>'1',4=>'2',5=>'3',6=>'1',7=>1,8=>2],0)", "[lib/DB/Cortex.php:580] DB\Cortex->filteredFind(['start_date >= ? AND end_date <= ?','2015-12-01','2015-12-31'],NULL,0)",

ikkez commented 8 years ago

alright. must be something with the new regex and some _ chars. I'll review this.

ikkez commented 8 years ago

should be fixed now.

jekabsmilbrets commented 8 years ago

yes, thank you! :)