packages feed

qhs 0.4.0 → 0.4.1

raw patch · 4 files changed

+13/−5 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016-2025 itchyny+Copyright (c) 2016-2026 itchyny  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
qhs.cabal view
@@ -1,6 +1,6 @@ cabal-version:          3.0 name:                   qhs-version:                0.4.0+version:                0.4.1 category:               Console synopsis:               Command line tool qhs, SQL queries on CSV and TSV files. description:            This is a Haskell port of <https://github.com/harelba/q q command>.
src/Qhs/File.hs view
@@ -59,15 +59,17 @@ splitFixedSize :: (Char -> Bool) -> Int -> String -> [String] splitFixedSize f n = fill . go n   where go _ "" = []-        go k (c:cs@(c':_)) | f c && f c' && not (f ' ' && isSpace c') = "" : go (k - 1) cs-                           | f c = go k cs+        go k (c:cs) | f c =+          case cs of+               (c':_) | f c' && not (f ' ' && isSpace c') -> "" : go (k - 1) cs+               [] -> [""]+               _ -> go k cs         go k ('"':cs) = let (ys, xs) = takeQuotedString cs in xs : go (k - 1) ys           where takeQuotedString ('"':'"':xs) = fmap ('"':) (takeQuotedString xs)                 takeQuotedString ('\\':'"':xs) = fmap ('"':) (takeQuotedString xs)                 takeQuotedString ('"':xs) = (xs, "")                 takeQuotedString (x:xs) = fmap (x:) (takeQuotedString xs)                 takeQuotedString "" = ("", "")-        go k (c:cs) | f c = go k cs         go 1 cs = [cs]         go k cs = let (xs, ys) = break f cs in xs : go (k - 1) ys         fill [] = []
test/FileSpec.hs view
@@ -96,6 +96,12 @@       let (input, expected) = ("c0,c1,c2,,c3,,,c4", [ "c0", "c1", "c2", "", "c3", "", "", "c4" ])       splitFixedSize (==',') 0 input `shouldBe` expected +    it "should handle trailing delimiters" do+      splitFixedSize (=='\t') 0 "foo\t" `shouldBe` [ "foo", "" ]+      splitFixedSize (=='\t') 0 "foo\t\t" `shouldBe` [ "foo", "", "" ]+      splitFixedSize (==',') 0 "a,b," `shouldBe` [ "a", "b", "" ]+      splitFixedSize (==',') 0 "a,," `shouldBe` [ "a", "", "" ]+     it "should take the column size into account when splitting with (==',')" do       let (input, (n1, expected1), (n2, expected2), (n3, expected3), (n4, expected4))             = ("c0,c1,,c2,foo bar baz,c4",