(isRaw bool)
| 124 | } |
| 125 | |
| 126 | func NewSQLite(isRaw bool) func(baker.OutputParams) (baker.Output, error) { |
| 127 | return func(cfg baker.OutputParams) (baker.Output, error) { |
| 128 | // Convert and validate configuration |
| 129 | var dcfg *SQLiteRawWriterConfig |
| 130 | if isRaw { |
| 131 | dcfg = cfg.DecodedConfig.(*SQLiteRawWriterConfig) |
| 132 | } else { |
| 133 | dcfg = cfg.DecodedConfig.(*SQLiteConfig).convert() |
| 134 | } |
| 135 | |
| 136 | path, err := renderSQLitePathString(dcfg.PathString, cfg.Index, "") |
| 137 | if err != nil { |
| 138 | return nil, fmt.Errorf("can't render PathString: %s", err) |
| 139 | } |
| 140 | |
| 141 | // Make a record of all field names; they will be needed when we create |
| 142 | // an SQL table in the SQLite file. |
| 143 | var fieldNames []string |
| 144 | for _, fidx := range cfg.Fields { |
| 145 | fieldNames = append(fieldNames, cfg.FieldNames[fidx]) |
| 146 | } |
| 147 | |
| 148 | sqlw := &SQLite{ |
| 149 | cfg: dcfg, |
| 150 | pathString: path, |
| 151 | fieldNames: fieldNames, |
| 152 | isRaw: isRaw, |
| 153 | } |
| 154 | |
| 155 | if err = sqlw.setup(); err != nil { |
| 156 | return nil, fmt.Errorf("setup error: %v", err) |
| 157 | } |
| 158 | |
| 159 | return sqlw, nil |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func (c *SQLite) setup() error { |
| 164 | var err error |
no test coverage detected