Skip to content

Commit

Permalink
FIX #21294 Stock import sql query
Browse files Browse the repository at this point in the history
To respect the PostgreSQL update statement syntax, cf.
https://www.postgresql.org/docs/17/sql-update.html

```
column_name
    The name of a column in the table named by table_name. The column name can
    be qualified with a subfield name or array subscript, if needed. Do not
    include the table's name in the specification of a target column — for
    example, UPDATE table_name SET table_name.col = 1 is invalid.
```

Signed-off-by: Alexis Thietard <[email protected]>
  • Loading branch information
Al-thi committed Jan 6, 2025
1 parent 67c2a48 commit b7cb799
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion htdocs/core/modules/modStock.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function __construct($db)
);
$this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse");
$this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after.
'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'
'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'
);
}

Expand Down

0 comments on commit b7cb799

Please sign in to comment.