error when using postgresql on version 3.3

ayahfathimah9 years ago

Hello,

I got following error in traccar.log when using traccar server 3.3

2016-02-14 00:41:33  WARN: ERROR: column "userid" does not exist
  Position: 8 - PSQLException (... < QueryBuilder:376 < DataManager:227 < PermissionsManager:59 < ...)
2016-02-14 00:41:33  WARN: ERROR: column "positionid" does not exist
  Position: 45 - PSQLException (... < QueryBuilder:376 < DataManager:324 < ConnectionManager:55 < ...)

also when trying to add new device in web app I got following error:

ERROR: column "uniqueid" of relation "devices" does not exist Position: 28 - PSQLException (... < QueryBuilder:431 < DataManager:244 < DeviceResource:59 < ...)

it seems somehow the column name is changed to lowercase in query.

could you please help in solving this issue?
and also the documentation in https://www.traccar.org/postgresql/ seems no more applicable in 3.3

--
Change INT PRIMARY KEY AUTO_INCREMENT to SERIAL PRIMARY KEY
Change BIT to BOOLEAN
For boolean fields with default values change 0 to FALSE and 1 to TRUE
Remove parentheses from CURRENT_TIMESTAMP

Thanks

Anton Tananaev9 years ago

Please try latest changelogs from here:

https://github.com/tananaev/traccar/tree/master/database

Re-create the database or remove all tables before trying it.

ayahfathimah9 years ago

I tried as you suggested, but the errors still happen.

I manage to make it works when I double quoted all column names which contains uppercase characters as following:

<entry key='database.selectServers'>
        SELECT * FROM server;
    </entry>

    <entry key='database.updateServer'>
        UPDATE server SET
        registration = :registration,
        readonly = :readonly,
        map = :map,
        "bingKey" = :bingKey,
        "mapUrl" = :mapUrl,
        language = :language,
        "distanceUnit" = :distanceUnit,
        "speedUnit" = :speedUnit,
        latitude = :latitude,
        longitude = :longitude,
        zoom = :zoom
        WHERE id = :id;
    </entry>

    <entry key='database.loginUser'>
        SELECT * FROM users
        WHERE email = :email;
    </entry>

    <entry key='database.selectUser'>
        SELECT * FROM users
        WHERE id = :id;
    </entry>

    <entry key='database.selectUsersAll'>
        SELECT * FROM users;
    </entry>

    <entry key='database.insertUser'>
        INSERT INTO users (name, email, "hashedPassword", salt, admin)
        VALUES (:name, :email, :hashedPassword, :salt, :admin);
    </entry>

    <entry key='database.updateUser'>
        UPDATE users SET
        name = :name,
        email = :email,
        admin = :admin,
        map = :map,
        language = :language,
        "distanceUnit" = :distanceUnit,
        "speedUnit" = :speedUnit,
        latitude = :latitude,
        longitude = :longitude,
        zoom = :zoom
        WHERE id = :id;
    </entry>

    <entry key='database.updateUserPassword'>
        UPDATE users SET "hashedPassword" = :hashedPassword, salt = :salt WHERE id = :id;
    </entry>

    <entry key='database.deleteUser'>
        DELETE FROM users WHERE id = :id;
    </entry>

    <entry key='database.getPermissionsAll'>
        SELECT "userId", "deviceId" FROM user_device;
    </entry>

    <entry key='database.selectDevicesAll'>
        SELECT * FROM devices;
    </entry>

    <entry key='database.selectDevices'>
        SELECT * FROM devices d INNER JOIN user_device ud ON d.id = ud."deviceId" WHERE ud."userId" = :userId;
    </entry>

    <entry key='database.insertDevice'>
        INSERT INTO devices (name, "uniqueId") VALUES (:name, :uniqueId);
    </entry>

    <entry key='database.updateDevice'>
        UPDATE devices SET name = :name, "uniqueId" = :uniqueId WHERE id = :id;
    </entry>

    <entry key='database.updateDeviceStatus'>
        UPDATE devices SET status = :status, "lastUpdate" = :lastUpdate WHERE id = :id;
    </entry>

    <entry key='database.deleteDevice'>
        DELETE FROM devices WHERE id = :id;
    </entry>

    <entry key='database.linkDevice'>
        INSERT INTO user_device ("userId", "deviceId") VALUES (:userId, :deviceId);
    </entry>

    <entry key='database.unlinkDevice'>
        DELETE FROM user_device WHERE "userId" = :userId AND "deviceId" = :deviceId;
    </entry>

    <entry key='database.selectPositions'>
        SELECT * FROM positions WHERE "deviceId" = :deviceId AND "fixTime" BETWEEN :from AND :to ORDER BY "fixTime";
    </entry>

    <entry key='database.insertPosition'>
        INSERT INTO positions ("deviceId", protocol, "serverTime", "deviceTime", "fixTime", valid, latitude, longitude, altitude, speed, course, address, attributes)
        VALUES (:deviceId, :protocol, :now, :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :attributes);
    </entry>

    <entry key='database.selectLatestPositions'>
        SELECT * FROM positions WHERE id IN (SELECT "positionId" FROM devices);
    </entry>

    <entry key='database.updateLatestPosition'>
        UPDATE devices SET "positionId" = :id WHERE id = :deviceId;
    </entry>

but I am not sure yet whether everything works fine or not. Especially I am still not sure whether following notation ud."deviceId" is correct:

    <entry key='database.selectDevices'>
        SELECT * FROM devices d INNER JOIN user_device ud ON d.id = ud."deviceId" WHERE ud."userId" = :userId;
    </entry>
Anton Tananaev9 years ago

Column names shouldn't be case sensitive. Not sure why they are.