@@ -13,17 +13,27 @@ PrettyPrinting.quoteof(::EmptyType) =
1313 Expr (:call , nameof (EmptyType))
1414
1515struct ScalarType <: AbstractSQLType
16+ visible:: Bool
17+
18+ ScalarType (; visible = true ) =
19+ new (visible)
1620end
1721
18- PrettyPrinting. quoteof (:: ScalarType ) =
19- Expr (:call , nameof (ScalarType))
22+ function PrettyPrinting. quoteof (:: ScalarType )
23+ ex = Expr (:call , nameof (ScalarType))
24+ if ! t. visible
25+ push! (ex. args, Expr (:kw , :visible , t. visible))
26+ end
27+ ex
28+ end
2029
2130struct RowType <: AbstractSQLType
2231 fields:: OrderedDict{Symbol, Union{ScalarType, RowType}}
2332 group:: Union{EmptyType, RowType}
33+ visible:: Bool
2434
25- RowType (fields, group = EmptyType ()) =
26- new (fields, group)
35+ RowType (fields, group = EmptyType (); visible = true ) =
36+ new (fields, group, visible )
2737end
2838
2939const FieldTypeMap = OrderedDict{Symbol, Union{ScalarType, RowType}}
@@ -43,6 +53,9 @@ function PrettyPrinting.quoteof(t::RowType)
4353 if ! (t. group isa EmptyType)
4454 push! (ex. args, Expr (:kw , :group , quoteof (t. group)))
4555 end
56+ if ! t. visible
57+ push! (ex. args, Expr (:kw , :visible , t. visible))
58+ end
4659 ex
4760end
4861
@@ -54,8 +67,8 @@ const EMPTY_ROW = RowType()
5467Base. intersect (:: AbstractSQLType , :: AbstractSQLType ) =
5568 EmptyType ()
5669
57- Base. intersect (:: ScalarType , :: ScalarType ) =
58- ScalarType ()
70+ Base. intersect (t1 :: ScalarType , t2 :: ScalarType ) =
71+ ScalarType (visible = t1 . visible || t2 . visible )
5972
6073function Base. intersect (t1:: RowType , t2:: RowType )
6174 if t1 === t2
@@ -71,7 +84,7 @@ function Base.intersect(t1::RowType, t2::RowType)
7184 end
7285 end
7386 group = intersect (t1. group, t2. group)
74- RowType (fields, group)
87+ RowType (fields, group, visible = t1 . visible || t2 . visible )
7588end
7689
7790
@@ -98,5 +111,8 @@ function Base.issubset(t1::RowType, t2::RowType)
98111 if ! issubset (t1. group, t2. group)
99112 return false
100113 end
114+ if ! t1. visible && t2. visible
115+ return false
116+ end
101117 return true
102118end
0 commit comments