Skip to content

Commit 0b9884c

Browse files
committed
no more negative prices
1 parent a19b7f3 commit 0b9884c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

kafka-questdb-connector-samples/stocks/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
Postgres -> Kafka:
24
```shell
35
curl -X POST -H "Content-Type: application/json" -d '{"name":"debezium_source","config":{"tasks.max":1,"database.hostname":"postgres","database.port":5432,"database.user":"postgres","database.password":"postgres","connector.class":"io.debezium.connector.postgresql.PostgresConnector","database.dbname":"postgres","database.server.name":"dbserver1"}} ' localhost:8083/connectors

kafka-questdb-connector-samples/stocks/src/main/java/io/questdb/kafka/samples/StockRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public interface StockRepository extends CrudRepository<Stock, String> {
1919

2020
@Modifying
21-
@Query("UPDATE stock SET price = price + :delta, last_update = :timestamp WHERE symbol = :symbol")
21+
@Query("UPDATE stock SET price = GREATEST(0, price + :delta), last_update = :timestamp WHERE symbol = :symbol")
2222
boolean updateBySymbol(@Param("symbol") String symbol, @Param("delta") double delta, @Param("timestamp") Timestamp timestamp);
2323

2424
@Query("SELECT symbol FROM stock")

0 commit comments

Comments
 (0)