MCPcopy Create free account
hub / github.com/AfterShip/clickhouse-sql-parser / FormatSQL

Method FormatSQL

parser/format.go:1776–1816  ·  view source on GitHub ↗
(formatter *Formatter)

Source from the content-addressed store, hash-verified

1774}
1775
1776func (j *JSONOptions) FormatSQL(formatter *Formatter) {
1777 formatter.WriteByte('(')
1778 // Ensure stable, readable ordering:
1779 // 1) numeric options (max_dynamic_*), 2) type-hint items, 3) skip options (SKIP, SKIP REGEXP)
1780 // Preserve original relative order within each group.
1781 numericOptionItems := make([]*JSONOption, 0, len(j.Items))
1782 columnItems := make([]*JSONOption, 0, len(j.Items))
1783 skipOptionItems := make([]*JSONOption, 0, len(j.Items))
1784 for _, item := range j.Items {
1785 if item.MaxDynamicPaths != nil || item.MaxDynamicTypes != nil {
1786 numericOptionItems = append(numericOptionItems, item)
1787 continue
1788 }
1789 if item.Column != nil {
1790 columnItems = append(columnItems, item)
1791 continue
1792 }
1793 if item.SkipPath != nil || item.SkipRegex != nil {
1794 skipOptionItems = append(skipOptionItems, item)
1795 continue
1796 }
1797 // Fallback: treat as numeric option to avoid dropping unknown future fields.
1798 numericOptionItems = append(numericOptionItems, item)
1799 }
1800
1801 wroteItem := false
1802 writeItems := func(items []*JSONOption) {
1803 for _, item := range items {
1804 if wroteItem {
1805 formatter.WriteString(", ")
1806 }
1807 item.FormatSQL(formatter)
1808 wroteItem = true
1809 }
1810 }
1811
1812 writeItems(numericOptionItems)
1813 writeItems(columnItems)
1814 writeItems(skipOptionItems)
1815 formatter.WriteByte(')')
1816}
1817
1818func (j *JSONType) FormatSQL(formatter *Formatter) {
1819 formatter.WriteExpr(j.Name)

Callers

nothing calls this directly

Calls 3

WriteByteMethod · 0.80
WriteStringMethod · 0.80
FormatSQLMethod · 0.65

Tested by

no test coverage detected