cs50 / problems

Checks for check50
145 stars 237 forks source link

CS50SQL Private will not pass solutions which use Triggers due to parsing of the .sql file. #198

Closed nighanxiety closed 1 year ago

nighanxiety commented 1 year ago

In private/init.py, the run_statements function parses the private.sql file with the rollowing regular expression:

queries = re.findall(r".*?;", contents, re.DOTALL)

A TRIGGER statement contains multiple semi-colons, so this will result in check50 returning the error:

:( private.sql runs without error
    Error when executing statements: incomplete input

Because it finds the ';' at the end of the inner statement, and then "END;" is missing from the query

Possible solutions: 1) Temporarily warn students that TRIGGERS can't be used in the solution 2) Before running the queries, loop over them and find any query including the words "TRIGGER" and "BEGIN", then merge it with subsequent elements of the queries list until the element with "END;" is found.

CarterZenke commented 1 year ago

Thank you, @nighanxiety, this should now be fixed with 157c11f.