Skip to content

Commit

Permalink
Add expected-to-fail test against issue #157
Browse files Browse the repository at this point in the history
  • Loading branch information
lelit committed Oct 29, 2024
1 parent 26fedf4 commit 2c17b0a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,32 @@ def used_tables(sql_query):
'''

assert used_tables(turkish_chars) == {'Schema.Table', 'Schema2.Table2'}


@pytest.mark.xfail
def test_issue157():
# See https://github.com/pganalyze/libpg_query/issues/261

query = """\
CREATE OR REPLACE FUNCTION update_customer_total_sales(customer_id INT)
RETURNS VOID AS $$
DECLARE
total NUMERIC;
BEGIN
-- Calculate the total sales for the specified customer
SELECT COALESCE(SUM(amount), 0) INTO total
FROM orders
WHERE customer_id $1; -- <------ this part is invalid
-- Update the total_sales in the customers table
UPDATE customers
SET total_sales = total
WHERE customer_id;
-- Optionally, you can return the total for confirmation
RAISE NOTICE 'Total sales for customer ID %: %', customer_id, total;
END;
$$ LANGUAGE plpgsql"""

with pytest.raises(Error) as exc:
parse_plpgsql(query)

0 comments on commit 2c17b0a

Please sign in to comment.