(pos Pos)
| 2044 | } |
| 2045 | |
| 2046 | func (p *Parser) parseDictionaryAttribute(pos Pos) (*DictionaryAttribute, error) { |
| 2047 | name, err := p.parseIdent() |
| 2048 | if err != nil { |
| 2049 | return nil, err |
| 2050 | } |
| 2051 | |
| 2052 | columnType, err := p.parseColumnType(p.Pos()) |
| 2053 | if err != nil { |
| 2054 | return nil, err |
| 2055 | } |
| 2056 | |
| 2057 | attr := &DictionaryAttribute{ |
| 2058 | NamePos: pos, |
| 2059 | Name: name, |
| 2060 | Type: columnType, |
| 2061 | } |
| 2062 | |
| 2063 | // Parse optional attribute properties |
| 2064 | for { |
| 2065 | switch { |
| 2066 | case p.tryConsumeKeywords(KeywordDefault): |
| 2067 | if attr.Default != nil { |
| 2068 | return nil, fmt.Errorf("duplicate DEFAULT clause") |
| 2069 | } |
| 2070 | literal, err := p.parseLiteral(p.Pos()) |
| 2071 | if err != nil { |
| 2072 | return nil, err |
| 2073 | } |
| 2074 | attr.Default = literal |
| 2075 | case p.tryConsumeKeywords(KeywordExpression): |
| 2076 | if attr.Expression != nil { |
| 2077 | return nil, fmt.Errorf("duplicate EXPRESSION clause") |
| 2078 | } |
| 2079 | expr, err := p.parseExpr(p.Pos()) |
| 2080 | if err != nil { |
| 2081 | return nil, err |
| 2082 | } |
| 2083 | attr.Expression = expr |
| 2084 | case p.tryConsumeKeywords(KeywordHierarchical): |
| 2085 | if attr.Hierarchical { |
| 2086 | return nil, fmt.Errorf("duplicate HIERARCHICAL clause") |
| 2087 | } |
| 2088 | attr.Hierarchical = true |
| 2089 | case p.tryConsumeKeywords(KeywordInjective): |
| 2090 | if attr.Injective { |
| 2091 | return nil, fmt.Errorf("duplicate INJECTIVE clause") |
| 2092 | } |
| 2093 | attr.Injective = true |
| 2094 | case p.tryConsumeKeywords(KeywordIs_object_id): |
| 2095 | if attr.IsObjectId { |
| 2096 | return nil, fmt.Errorf("duplicate IS_OBJECT_ID clause") |
| 2097 | } |
| 2098 | attr.IsObjectId = true |
| 2099 | default: |
| 2100 | // No more attribute properties |
| 2101 | return attr, nil |
| 2102 | } |
| 2103 | } |
no test coverage detected