Skip to content

Add a better example for INSERT INTO #134

Description

@richierocks

The docs give this INSERT INTO example.

Solution

INSERT INTO company VALUES (2, 'filip', 28, 'sql-lane', 42)

SCT

Ex().check_query('SELECT COUNT(*) AS c FROM company').has_equal_value()

This is weak because it only check that a row was added, not the contents.

I suggest a better check to include in the documentation.

Ex().check_correct(
  check_query("SELECT COUNT(*) FROM company WHERE name = 'filip' AND age = 28 AND street = 'sql-lane' AND house_number = 42").has_equal_value(incorrect_msg = "Did you use `INSERT INTO` to insert a row into `company`?"),
  multi(
    check_query("SELECT COUNT(*) FROM company WHERE name = 'filip'").has_equal_value(incorrect_msg = "Did you insert a row into `company` with `name` equal to `'filip'`?"),
    check_query("SELECT COUNT(*) FROM company WHERE age = 28").has_equal_value(incorrect_msg = "Did you insert a row into `company` with `age` equal to `28`?"),
    check_query("SELECT COUNT(*) FROM company WHERE street = 'sql-lane'").has_equal_value(incorrect_msg = "Did you insert a row into `company` with `street` equal to `'sql-lane'`?"),
    check_query("SELECT COUNT(*) FROM company WHERE house_number = 42").has_equal_value(incorrect_msg = "Did you insert a row into `company` with `house_number` equal to `42`?")
  )
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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