Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Make sure we only import directory #40

Merged
merged 2 commits into from
Dec 21, 2017
Merged

Conversation

safareli
Copy link
Contributor

No description provided.

import `foo/`; select * from `/test`
"""

parseFail """
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BREAKING. Is there a way to not make it braking?

genSqlQueryF n = Query <$> genDecls n <*> pure n

genSqlModuleF ∷ ∀ m. Gen.MonadGen m ⇒ CoalgebraM m SqlModuleF Int
genSqlModuleF ∷ ∀ m. Gen.MonadGen m ⇒ MonadRec m ⇒ CoalgebraM m SqlModuleF Int
Copy link
Contributor Author

@safareli safareli Dec 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BREAKING. As new constraint is introduced (that's needed for generating of path-es)

@safareli safareli requested review from garyb and cryogenian December 20, 2017 21:22
Copy link
Member

@cryogenian cryogenian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, change a >>> b <$> c to b <<< a <$> c 🙏

Also two small things to consider

  • wrapped forall a. -- I might be wrong but the quantifier could be moved to the left
  • It would be cool if we had print/parse for table relation

printAnyDirPath :: AnyDirPath -> String
printAnyDirPath = E.either Pt.unsafePrintPath Pt.unsafePrintPath

parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDirPath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we move a to the left?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to do this

forall m. (forall a. String -> a) -> any ~ 
forall m. (exists a. (String -> a) -> any) ~ 
forall m a. (String -> a) -> any

Copy link
Contributor Author

@safareli safareli Dec 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved a to top forall but it fails with:

[1/1 TypesDoNotUnify] src/SqlSquared/Path.purs:41:4

  41    (pure ∘ E.Right)
         ^^^^^^^^^^^^^^
  
  Could not match type
  
    Either t4 (Path Rel File Unsandboxed)
  
  with type
  
    a1
  
  while trying to match type t2 t3
    with type m0 a1
  while checking that expression (compose pure) Right
    has type Path Rel File Unsandboxed -> m0 a1
  in value declaration parseAnyFilePath
  
  where a1 is a rigid type variable
        m0 is a rigid type variable
        t3 is an unknown type
        t2 is an unknown type
        t4 is an unknown type

so reverting to inner forall

@@ -138,8 +142,20 @@ data SqlF literal a
| Select (SelectR a)
| Parens a

type AnyDirPath = E.Either (Pt.AbsDir Pt.Unsandboxed) (Pt.RelDir Pt.Unsandboxed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worthing to introduce the same type and print/parse for filepath. It's used in table relation.

genImport ∷ ∀ m a. Gen.MonadGen m ⇒ MonadRec m ⇒ m (SqlDeclF a)
genImport = map Import
$ Gen.oneOf
$ (Pt.unsandbox >>> E.Left <$> PtGen.genAbsDirPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flipped flow. Pt.unsandbox >>> E.Left left-to-right, <$> right-to-left. It's hard to follow, would you mind switching to E.Left <<< Pt.unsandbox <$> PtGen.genAbsDirPath or Pt.genAbsDirPath <#> Pt.unsandbox >>> E.Left?

(pure ∘ E.Right)
(pure ∘ E.Left)
(const $ fail "incorrect directory path")
(const $ fail "incorrect directory path")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I think "incorrect directory path" is an easy error for users to misinterpret. Perhaps "Expected a directory path"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely!

@safareli
Copy link
Contributor Author

Made requested changes.

@cryogenian
Copy link
Member

Awesome! Thank you very much!

@cryogenian
Copy link
Member

Besides broken travis of course :P

@safareli
Copy link
Contributor Author

So the braking part of the change is fine? i.e. queries which were fine will be rejected after upgrade.

@safareli
Copy link
Contributor Author

This is passing now.

What should be a new version? (v0.9.1 is current one )

@cryogenian
Copy link
Member

Yeah, breaking incorrect queries is absolutely fine, they didn't work in quasar anyways.
I'd make it 0.10.0

@safareli safareli merged commit d3a6cfa into slamdata:master Dec 21, 2017
@safareli safareli deleted the import branch December 21, 2017 15:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants