datacamp / sqlwhat

https://sqlwhat.readthedocs.io
GNU Affero General Public License v3.0
3 stars 8 forks source link

Feature sct compose #89

Closed machow closed 7 years ago

machow commented 7 years ago

Allows composition over SCT functions, via the + operator. Note that I'm putting this here so we can discuss the idea. Other operators, such as > or >> are available (and have been used to do similar things in other libraries).

E.g.

sel = Ex().check_node("SelectStmt")
tv = check_field("target_value")

# combine
sel + tv

# equivalent to
sel.extend(tv)

# equivalent to 
Ex().check_node("SelectStmt").check_field("target_value")

# similar to below (except multi doesn't return the child state from tv)
sel.multi(tv)

# could also do the following, since tv is just an F instance
sel + tv.has_equal_ast()
filipsch commented 7 years ago

@machow like the idea, but indeed let's discuss. The API's power is in its simplicity right now, and I wouldn't want to break that.

filipsch commented 7 years ago

Are you closing this for now, then?

machow commented 7 years ago

I'll document and merge it in tomorrow. The extend function will be useful, and sql courses are slow enough that we can remove the + operator if it isn't useful.

filipsch commented 7 years ago

We really need closure on this, @machow;

machow commented 7 years ago

I added this to the staging branch and made it available for the intro-sql course. I'll set up office hours on Tues to get Colin's feedback on it.

filipsch commented 7 years ago

@machow any news on the feedback?

machow commented 7 years ago

Discussed in pairing, but putting here for posterity--got feedback from @colinricardo, will change + to >> and mergeeeee