Skip to content

Commit

Permalink
Use effective, and select correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeyer18 committed May 21, 2024
1 parent 35dc030 commit f36874c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ALTER TABLE mesoscaleDiscussionV2 DROP probabilityOfWatchIssuance;
ALTER TABLE mesoscaleDiscussionV2 DROP expires;
ALTER TABLE mesoscaleDiscussionV2 DROP valid;
ALTER TABLE mesoscaleDiscussionV2 DROP effective;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ALTER TABLE mesoscaleDiscussionV2 ADD probabilityOfWatchIssuance INT;
ALTER TABLE mesoscaleDiscussionV2 ADD expires TIMESTAMP WITH TIME ZONE;
ALTER TABLE mesoscaleDiscussionV2 ADD valid TIMESTAMP WITH TIME ZONE;
ALTER TABLE mesoscaleDiscussionV2 ADD effective TIMESTAMP WITH TIME ZONE;
12 changes: 9 additions & 3 deletions sql/mesoscale_discussion_v2_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewPostgresMesoscaleDiscussionV2Table(db *sql.DB) PostgresMesoscaleDiscussi
func (p *PostgresMesoscaleDiscussionV2Table) Insert(md data_structures.MesoscaleDiscussionV2) error {
//language=SQL
statement, err := p.db.Prepare(`
INSERT INTO mesoscaleDiscussionV2 (id, number, year, geometry, rawText, probabilityOfWatchIssuance, valid, expires)
INSERT INTO mesoscaleDiscussionV2 (id, number, year, geometry, rawText, probabilityOfWatchIssuance, effective, expires)
VALUES (
$1,
$2,
Expand Down Expand Up @@ -69,7 +69,7 @@ func (p *PostgresMesoscaleDiscussionV2Table) Insert(md data_structures.Mesoscale
}

func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_structures.MesoscaleDiscussionV2, error) {
statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText FROM mesoscaleDiscussionV2 WHERE year = $1 AND mdNumber = $2`)
statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText, probabilityOfWatchIssuance, effective, expires FROM mesoscaleDiscussionV2 WHERE year = $1 AND mdNumber = $2`)
if err != nil {
return nil, err
}
Expand All @@ -84,6 +84,9 @@ func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_s
&md.Year,
&marshalledGeometry,
&md.RawText,
&md.ProbabilityOfWatchIssuance,
&md.Effective,
&md.Expires,
)
if err != nil {
return nil, err
Expand All @@ -100,7 +103,7 @@ func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_s
}

func (p *PostgresMesoscaleDiscussionV2Table) SelectById(id string) (*data_structures.MesoscaleDiscussionV2, error) {
statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText FROM mesoscaleDiscussionV2 WHERE id = $1`)
statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText, probabilityOfWatchIssuance, effective, expires FROM mesoscaleDiscussionV2 WHERE id = $1`)
if err != nil {
return nil, err
}
Expand All @@ -115,6 +118,9 @@ func (p *PostgresMesoscaleDiscussionV2Table) SelectById(id string) (*data_struct
&md.Year,
&marshalledGeometry,
&md.RawText,
&md.ProbabilityOfWatchIssuance,
&md.Effective,
&md.Expires,
)
if err != nil {
return nil, err
Expand Down

0 comments on commit f36874c

Please sign in to comment.