You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/01/17 03:01:41 UTC

[incubator-devlake] branch main updated: feat: add `dal.RawCursor` back for compatibility (#4216)

This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new c2a1e8d39 feat: add `dal.RawCursor` back for compatibility (#4216)
c2a1e8d39 is described below

commit c2a1e8d3978dd133aa8f98a217584b98cb3384d5
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Jan 17 11:01:38 2023 +0800

    feat: add `dal.RawCursor` back for compatibility (#4216)
---
 backend/core/dal/dal.go          | 2 ++
 backend/impls/dalgorm/dalgorm.go | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/backend/core/dal/dal.go b/backend/core/dal/dal.go
index 53541b282..af2f93dff 100644
--- a/backend/core/dal/dal.go
+++ b/backend/core/dal/dal.go
@@ -143,6 +143,8 @@ type Dal interface {
 	IsErrorNotFound(err errors.Error) bool
 	// IsDuplicationError returns true if error is duplicate-error
 	IsDuplicationError(err errors.Error) bool
+	// RawCursor (Deprecated) executes raw sql query and returns a database cursor.
+	RawCursor(query string, params ...interface{}) (*sql.Rows, errors.Error)
 }
 
 type Transaction interface {
diff --git a/backend/impls/dalgorm/dalgorm.go b/backend/impls/dalgorm/dalgorm.go
index 04604819a..a4f122305 100644
--- a/backend/impls/dalgorm/dalgorm.go
+++ b/backend/impls/dalgorm/dalgorm.go
@@ -364,6 +364,11 @@ func (d *Dalgorm) IsDuplicationError(err errors.Error) bool {
 	return strings.Contains(strings.ToLower(err.Error()), "duplicate")
 }
 
+// RawCursor (Deprecated) executes raw sql query and returns a database cursor
+func (d *Dalgorm) RawCursor(query string, params ...interface{}) (*sql.Rows, errors.Error) {
+	return errors.Convert01(d.db.Raw(query, params...).Rows())
+}
+
 // NewDalgorm creates a *Dalgorm
 func NewDalgorm(db *gorm.DB) *Dalgorm {
 	return &Dalgorm{db}