Fix sql rules