(table *Table, whereCommand *ast.WhereCommand, negation bool, tableName string)
| 519 | } |
| 520 | |
| 521 | func (engine *DbEngine) getFilteredTable(table *Table, whereCommand *ast.WhereCommand, negation bool, tableName string) (*Table, error) { |
| 522 | filteredTable := getCopyOfTableWithoutRows(table) |
| 523 | |
| 524 | identifiers := whereCommand.Expression.GetIdentifiers() |
| 525 | columnNames := make([]string, 0) |
| 526 | for _, identifier := range identifiers { |
| 527 | columnNames = append(columnNames, identifier.Token.Literal) |
| 528 | } |
| 529 | missingColumnName := engine.getMissingColumnName(columnNames, table) |
| 530 | if missingColumnName != "" { |
| 531 | return nil, &ColumnDoesNotExistError{tableName: tableName, columnName: missingColumnName} |
| 532 | } |
| 533 | |
| 534 | for _, row := range MapTableToRows(table).rows { |
| 535 | fulfilledFilters, err := isFulfillingFilters(row, whereCommand.Expression, whereCommand.Token.Literal) |
| 536 | if err != nil { |
| 537 | return nil, err |
| 538 | } |
| 539 | |
| 540 | if xor(fulfilledFilters, negation) { |
| 541 | for _, filteredColumn := range filteredTable.Columns { |
| 542 | value := row[filteredColumn.Name] |
| 543 | filteredColumn.Values = append(filteredColumn.Values, value) |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | return filteredTable, nil |
| 548 | } |
| 549 | |
| 550 | func (engine *DbEngine) joinTables(joinCommand *ast.JoinCommand, leftTableName string) (*Table, error) { |
| 551 | leftTable, exist := engine.Tables[leftTableName] |
no test coverage detected