Replies: 1 comment 5 replies
-
| Hi @tevelee. The code we write in episodes is often simplified, as is the case here. In the current alpha of the library, it is not possible for that line to compile. While we do try to minimize the generation of invalid SQL, it is not a goal of the library to 100% catch every single edge case, and while none come to mind at the moment, I'm sure there are ways to generate invalid SQL if you try hard enough 😄 Our main goal is to provide a system that reasonably guides an individual already familiar with SQL. A user familiar with SQL should ideally recognize when a builder such as the one above is not valid, even if it did compile. | 
Beta Was this translation helpful? Give feedback.
                  
                    5 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi PointFree!
(Since the structured queries repo is still private, I'm sharing my feedback here)
In light of your recent episode concluding the
ORDER BYfunctionality and transitioning toWHEREclauses, I wanted to highlight a potential issue introduced in the latest update to the library that makes possible to produce invalid SQL syntax.By defining
ascanddescon theQueryExpressionprotocol…it’s now possible to write expressions like
Reminder.select { $0.title.asc() }, which generates invalid SQL. According to the documentation,ASCcan only be applied toordering-terms, not generalexprs.In my opinion, ordering term deserves its own distinct type/protocol in the library to ensure type safety so that
ascanddescfunctions are not available in.select {}, but other general expressions likelengthare applicable in both.select {}and.order {}.Have you considered implementing a validation layer — perhaps using a regular expression or a swift-parsing-based parser — to ensure that the generated SQL conforms to the expected grammar?
Beta Was this translation helpful? Give feedback.
All reactions