saltstack / saltstack/salt

[BUG] sqlite test doesn't report changes in a row

Open
#56,877 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Core help-wanted needs-testcase severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
When dry-run a sqlite state (test=true) it doesn't report changes in a row. However a normal run does a effective change.

Setup

{% set db = '/tmp/test.sqlite' %}
test_db:
  sqlite3.table_present:
    - name: test
    - db: {{ db }}
    - schema:
      - field1 TEXT PRIMARY KEY
      - field2 TEXT DEFAULT 'None'
  file.managed:
    - name: {{ db }}
    - user: root
    - group: root
    - mode: 0400

test_modify:
  sqlite3.row_present:
    - db: {{ db }}
    - table: test
    - where_sql: field1='test'
    - data:
        field1: test
        field2: test1,test2
    - update: True
    - require:
      - sqlite3: test_db

Steps to Reproduce the behavior

  • Run state for the first time to initiate de database
  • Change field2: test1,test2 to `field2: test1,test2,test3'
  • Dry-run the state (test=true) >> No changes
  • Execute the state >> 1 change!

Expected behavior

----------
          ID: test_modify
    Function: sqlite3.row_present
      Result: True
     Comment: Row will be updated in test
     Started: 09:17:01.494815
    Duration: 4.237 ms
     Changes:   ...........

Versions Report

salt --versions-report

Minion and master have same version level

Salt Version:
           Salt: 2019.2.3
 
Dependency Versions:
           cffi: 1.9.1
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: Not Installed
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.8 (default, Aug  7 2019, 17:28:10)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.2
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.7.1908 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1062.9.1.el7.x86_64
         system: Linux
        version: CentOS Linux 7.7.1908 Core

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sqlite3.row_present state entry point and reproduce the provided setup with test=true after changing field2. Compare the dry-run path with the normal execution path; done means the dry run reports that the row will be updated while the normal run still applies the change.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.