Skip to content

Commit

Permalink
Deprecate "derive default"
Browse files Browse the repository at this point in the history
Summary:
We can't remove the feature entirely, because it exists in the schema
in old DBs. So bump the Angle version and stop supporting it going
forwards, then we can remove it later.

Reviewed By: iamirzhan

Differential Revision: D68626170

fbshipit-source-id: 4189eea0c8b7b1e4f24565bdc325f084eb7455ea
  • Loading branch information
Simon Marlow authored and facebook-github-bot committed Jan 27, 2025
1 parent bf52076 commit 327bbf8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions glean/hs/Glean/Angle/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Control.Monad.Except
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB
import Data.Char
import Data.Either (partitionEithers)
import Data.List.NonEmpty (NonEmpty((:|)))
import Data.Maybe
Expand Down Expand Up @@ -272,7 +273,7 @@ derivewhen :: { Schema.DeriveWhen }
derivewhen
: {- empty -} { Schema.DeriveOnDemand }
| 'stored' { Schema.DerivedAndStored }
| 'default' { Schema.DeriveIfEmpty }
| 'default' {% ifVersionOrOlder (AngleVersion 11) $1 Schema.DeriveIfEmpty }
derivedecl :: { Schema.SourceDecl }
derivedecl
Expand Down Expand Up @@ -424,7 +425,7 @@ parseSchema bs = parseSchemaWithVersion ver rest

stripAngleVersion :: ByteString -> (AngleVersion, ByteString)
stripAngleVersion bs
| Just bs1 <- B.stripPrefix "version: " bs
| Just bs1 <- B.stripPrefix "version: " (B.dropWhile isSpace bs)
, Just (ver, bs2) <- B.readInt bs1 = (Schema.AngleVersion ver, bs2)
| otherwise = (latestAngleVersion, bs)
-- if the header is omitted, assume we are using the latest version
Expand Down
4 changes: 3 additions & 1 deletion glean/hs/Glean/Angle/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,14 @@ newtype AngleVersion = AngleVersion Int
-- - optional versions in `import`, `evolves`, inheritance
-- version 11:
-- - size primop
-- version 12:
-- - remove support for deriving default

latestSupportedAngleVersion :: AngleVersion
latestSupportedAngleVersion = AngleVersion 5

latestAngleVersion :: AngleVersion
latestAngleVersion = AngleVersion 11
latestAngleVersion = AngleVersion 12

-- -----------------------------------------------------------------------------
-- Pretty-printing
Expand Down
2 changes: 1 addition & 1 deletion glean/schema/source/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 10
version: 12
# This tells the Angle parser which version of the syntax we're using.
# NOTE: bump this version whenever we make a change to the syntax.
# NOTE: also change latestAngleVersion in glean/hs/Glean/Angle/Types.hs
2 changes: 2 additions & 0 deletions glean/test/tests/Schema/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ backwardCompatDeriving = TestCase $
schema_v1_file = root </> "schema1"
schema_v1 =
[s|
version: 11
schema test.1 {
predicate P : { a : string, b : nat }
predicate Q : { p : P }
Expand Down Expand Up @@ -530,6 +531,7 @@ deriveDefault = TestCase $
schema_v0_file = root </> "schema0"
schema_v0 =
[s|
version: 11
schema test.1 {
predicate P : { a : string, b : nat }
predicate Q : { p : P }
Expand Down

0 comments on commit 327bbf8

Please sign in to comment.