Abstrct / Schemaverse

The Schemaverse is a space-based strategy game implemented entirely within a PostgreSQL database. Compete against other players using raw SQL commands to command your fleet. Or, if your PL/pgSQL-foo is strong, wield it to write AI and have your fleet command itself!

Home Page:schemaverse.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting action/action_target_id not working with new ship insert.

MisterGlass opened this issue · comments

The goal of the example below is to create a new ship & set its action with one query:

      WITH new_ship as (
        INSERT INTO my_ships(
          name,
          attack, defense, engineering, prospecting,
          location,
          action,
          action_target_id
        )
        VALUES(
          'Miner',
          0,0,0,20,
          (SELECT location FROM planets WHERE id = 5),
          'MINE',
          5
        )
        RETURNING id
      )
      SELECT
        new_ship.id AS id,
        UPGRADE( new_ship.id, 'PROSPECTING', 480) AS status
      FROM new_ship

When executed, this query returns a success & create a ship, but DOES NOT set its action/action_target_id. This is a silent failure.

If possible, it would be great to get setting action/action_target_id working. Barring that, an error should be returned so that the client is aware of the issue.