Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug with _update function in sql_datastore.py #366

@zeinsteinz

Description

@zeinsteinz

Versions

  • Python: 3.5.2
  • OS: ubuntu 16.04
  • Pymodbus: 2.1.1-dev
  • Modbus Hardware (if used):

Pymodbus Specific

  • Server: tcp - sync/async
  • Client: tcp - sync/async

Description

The update statement used wrong column name.
In "query = self._table.update().values(name='value')", "name" should be "value". Since there is no column called "name", this will result in failure in update operation.

Code and Logs

starting from line 153 in sql_datastore.py

    def _update(self, type, offset, values):
        '''

        :param type: The type prefix to use
        :param offset: The address offset to start at
        :param values: The values to set
        '''
        context = self._build_set(type, offset, values, prefix='x_')
        query = self._table.update().values(name='value')
        query = query.where(and_(
            self._table.c.type == bindparam('x_type'),
            self._table.c.index == bindparam('x_index')))
        result = self._connection.execute(query, context)
        return result.rowcount == len(values)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions