From 0083f2887eac5875bd109b96bc585db669952dbf Mon Sep 17 00:00:00 2001 From: Alex Stevenson Date: Thu, 31 Jul 2025 15:53:38 -0400 Subject: [PATCH] Still trying to track down why Entities are returning correctly... --- main.go | 37 +++++++++++++++++++++++++------------ rpgqui.db | Bin 16384 -> 16384 bytes setup.sql | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index f898e93..dd81aaa 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,7 @@ func create_entity(db *sql.DB, user_id int64, spawn_line string) (Entity) { id, _ := res.LastInsertId() ent.id = id ent.user_id = user_id - ent.spawn_line = spawn_line + ent.spawn_line = spawn_line return ent } @@ -92,18 +92,20 @@ func get_entity(db *sql.DB, id int64) (Entity) { check(err) - var e Entity + var ent Entity res.Next() - res.Scan(&e.id, &e.user_id, &e.spawn_line) + res.Scan(&ent.id, &ent.user_id, &ent.spawn_line) +log.Println("WHY DOESN'T THIS WORK") +log.Printf("ID: %d, user_id: %d, spawn_line: %s", ent.id, ent.user_id, ent.spawn_line) res.Close() - if e.id != 0 { - return e - } else { + + if ent.id == 0 { log.Printf("Entity id %d doesn't exist!", id) - panic("!") } + + return ent } func reset_database(db *sql.DB) { @@ -121,16 +123,27 @@ func main() { reset_database(db) - log.Println("Reset db...") + log.Println("Reset db...\n") -// spin up a user... + log.Println("Adding users...\n") + // spin up a user... u := get_user(db, "Monqui") +log.Printf("ID: %d, name: %s", u.id, u.name) + u = get_user(db, "Jim") +log.Printf("ID: %d, name: %s", u.id, u.name) + u = get_user(db, "Monqui") +log.Printf("ID: %d, name: %s", u.id, u.name) -// make an entity for the user... + // make some entities... + log.Println("Adding entities...\n") e := create_entity(db, u.id, "hello im monqui") log.Printf("ID: %d, user_id: %d, spawn_line: %s", e.id, e.user_id, e.spawn_line) + e = create_entity(db, u.id, "here's a whole nother line!") +log.Printf("ID: %d, user_id: %d, spawn_line: %s", e.id, e.user_id, e.spawn_line) -// this should fail... - e = create_entity(db, 2, "hello im monqui???") + log.Println("Trying to fetch some entities...\n") + e = get_entity(db, 1) +log.Printf("ID: %d, user_id: %d, spawn_line: %s", e.id, e.user_id, e.spawn_line) + e = get_entity(db, 2) log.Printf("ID: %d, user_id: %d, spawn_line: %s", e.id, e.user_id, e.spawn_line) } diff --git a/rpgqui.db b/rpgqui.db index ad262f093a5e44a6dbfdbea1a559c3b772a81d1c..b4e9701626dcfab88edb17897a663f35f56b40bd 100644 GIT binary patch delta 250 zcmZo@U~Fh$oFFZ@mVtqR1&E=5k!hlivG7_3y*5o={vQm?e7y|(8T@DYdN&ISNb_+u zMliFB%gQn~Gf!T?C(6h&c^jV}r-Gk=0F^TX)$QQ7P+($Z;AC*lNG(cLFIGrYD9^~xNmam(|ZK95`umOW!n