feed_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
feedcollection_id INT NOT NULL REFERENCES feedcollections(feedcollection_id) ON DELETE CASCADE,
url VARCHAR NOT NULL,
- user VARCHAR,
- password VARCHAR,
+ auth_user VARCHAR,
+ auth_password VARCHAR,
certpath VARCHAR,
last_update TIMESTAMP
)
public fun newFeedGroup(name: String) : FeedGroup {
var groupId = 0
connection.prepareStatement("""
- insert into groups (pos, name) select max(pos)+1, ? from groups
+ insert into groups (pos, name) select coalesce(max(pos), 0)+1, ? from groups
""".trimIndent(), Statement.RETURN_GENERATED_KEYS).use { stmt ->
stmt.setString(1, name)
stmt.execute()
{
var feedcollectionId = -1
connection.prepareStatement("""
- insert into feedcollections (group_id, pos, name) select ?, max(pos)+1, ? from groups
- """.trimIndent()).use { stmt ->
+ insert into feedcollections (group_id, pos, name) select ?, coalesce(max(pos), 0)+1, ? from groups
+ """.trimIndent(), Statement.RETURN_GENERATED_KEYS).use { stmt ->
stmt.setInt(1, parent.id)
stmt.setString(2, name)
stmt.execute()
uris.forEach { uri ->
connection.prepareStatement("""
- insert into feeds (feedcollection_id, url, user, password, certpath)
- select ?, ?, ?, ?, ?
- from dual
- where not exists (select 1 from feeds where url = ?)
+ insert into feeds (feedcollection_id, url, auth_user, auth_password, certpath) values
+ (?, ?, ?, ?, ?)
""".trimIndent()).use { stmt ->
stmt.setInt(1, feedcollectionId)
stmt.setString(2, uri)