Skip to content

Commit 7c1be87

Browse files
authored
Version SQL functions to v1 (#30)
1 parent 0f05395 commit 7c1be87

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

postgresql/schemas/db-1.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ END;
161161
$$
162162
LANGUAGE plpgsql;
163163

164-
CREATE OR REPLACE FUNCTION real_medium.create_article(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[])
164+
CREATE OR REPLACE FUNCTION real_medium.create_article_v1(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[])
165165
RETURNS text
166166
AS $$
167167
DECLARE
@@ -192,6 +192,8 @@ END;
192192
$$
193193
LANGUAGE plpgsql;
194194

195+
196+
195197
CREATE OR REPLACE FUNCTION real_medium.is_favorited_article(_article_id text, _user_id text = NULL)
196198
RETURNS bool
197199
AS $$
@@ -217,7 +219,7 @@ BEGIN
217219
username,
218220
bio,
219221
image,
220-
CASE WHEN _follower_id = NULL THEN
222+
CASE WHEN _follower_id IS NULL THEN
221223
FALSE
222224
ELSE
223225
real_medium.is_following(_id, _follower_id)
@@ -230,7 +232,7 @@ END;
230232
$$
231233
LANGUAGE plpgsql;
232234

233-
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile(_article_id text, _follower_id text = NULL)
235+
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_v1(_article_id text, _follower_id text = NULL)
234236
RETURNS SETOF real_medium.tagged_article_with_author_profile
235237
AS $$
236238
BEGIN
@@ -259,7 +261,9 @@ END;
259261
$$
260262
LANGUAGE plpgsql;
261263

262-
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug(_slug varchar(255), _follower_id text = NULL)
264+
265+
266+
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug_v1(_slug varchar(255), _follower_id text = NULL)
263267
RETURNS SETOF real_medium.tagged_article_with_author_profile
264268
AS $$
265269
DECLARE
@@ -296,6 +300,8 @@ END;
296300
$$
297301
LANGUAGE plpgsql;
298302

303+
304+
299305
CREATE OR REPLACE FUNCTION real_medium.get_feed_articles(_user_id text, _limit int = 20, _offset int = 0)
300306
RETURNS SETOF real_medium.tagged_article_with_author_profile
301307
AS $$
@@ -400,5 +406,3 @@ LANGUAGE plpgsql;
400406
CREATE INDEX IF NOT EXISTS idx_createdat ON real_medium.articles(created_at DESC);
401407

402408
CREATE INDEX IF NOT EXISTS idx_tagname ON real_medium.tag_list(tag_name);
403-
404-

src/db/create_article.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT real_medium.create_article($1, $2, $3, $4, $5, $6)
1+
SELECT real_medium.create_article_v1($1, $2, $3, $4, $5, $6)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT real_medium.get_article_with_author_profile($1, $2)
1+
SELECT real_medium.get_article_with_author_profile_v1($1, $2)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT real_medium.get_article_with_author_profile_by_slug($1, $2)
1+
SELECT real_medium.get_article_with_author_profile_by_slug_v1($1, $2)

0 commit comments

Comments
 (0)