From 944fd98421fa4ec1b7871cd04fe16e38055db1bd Mon Sep 17 00:00:00 2001 From: sauls8t Date: Thu, 20 Sep 2018 11:12:17 +0100 Subject: [PATCH] Fixed up more SQL store breaking changes --- domain/attachment/mysql/store.go | 2 +- domain/block/mysql/store.go | 2 +- domain/category/mysql/store.go | 2 +- domain/document/mysql/store.go | 6 +++--- domain/group/mysql/store.go | 2 +- domain/link/mysql/store.go | 8 ++++---- domain/page/mysql/store.go | 2 +- domain/search/mysql/store.go | 2 +- gui/app/styles/view/search.scss | 2 +- server/server.go | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/domain/attachment/mysql/store.go b/domain/attachment/mysql/store.go index 96ab352d..62a95a3b 100644 --- a/domain/attachment/mysql/store.go +++ b/domain/attachment/mysql/store.go @@ -35,7 +35,7 @@ func (s Scope) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro bits := strings.Split(a.Filename, ".") a.Extension = bits[len(bits)-1] - _, err = ctx.Transaction.Exec("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_documentid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + _, err = ctx.Transaction.Exec("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_docid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", a.RefID, a.OrgID, a.DocumentID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised) if err != nil { diff --git a/domain/block/mysql/store.go b/domain/block/mysql/store.go index 49c85ba4..a4d335af 100644 --- a/domain/block/mysql/store.go +++ b/domain/block/mysql/store.go @@ -34,7 +34,7 @@ func (s Scope) Add(ctx domain.RequestContext, b block.Block) (err error) { b.Created = time.Now().UTC() b.Revised = time.Now().UTC() - _, err = ctx.Transaction.Exec("INSERT INTO dmz_section_template (c_refid, c_orgid, c_spaceid, c_userid, c_contenttype, c_type, c_name, c_body, c_desc, c_rawbody, c_config, c_external, used, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + _, err = ctx.Transaction.Exec("INSERT INTO dmz_section_template (c_refid, c_orgid, c_spaceid, c_userid, c_contenttype, c_type, c_name, c_body, c_desc, c_rawbody, c_config, c_external, c_used, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", b.RefID, b.OrgID, b.SpaceID, b.UserID, b.ContentType, b.Type, b.Name, b.Body, b.Excerpt, b.RawBody, b.Config, b.ExternalSource, b.Used, b.Created, b.Revised) if err != nil { diff --git a/domain/category/mysql/store.go b/domain/category/mysql/store.go index 50753c71..649abf2b 100644 --- a/domain/category/mysql/store.go +++ b/domain/category/mysql/store.go @@ -159,7 +159,7 @@ func (s Scope) AssociateDocument(ctx domain.RequestContext, m category.Member) ( m.Created = time.Now().UTC() m.Revised = time.Now().UTC() - _, err = ctx.Transaction.Exec("INSERT INTO dmz_category_member (c_refid, c_orgid, c_categoryid, c_spaceid, docid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?)", + _, err = ctx.Transaction.Exec("INSERT INTO dmz_category_member (c_refid, c_orgid, c_categoryid, c_spaceid, c_docid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?)", m.RefID, m.OrgID, m.CategoryID, m.SpaceID, m.DocumentID, m.Created, m.Revised) if err != nil { diff --git a/domain/document/mysql/store.go b/domain/document/mysql/store.go index 08a6f7af..fd381ee9 100644 --- a/domain/document/mysql/store.go +++ b/domain/document/mysql/store.go @@ -35,7 +35,7 @@ func (s Scope) Add(ctx domain.RequestContext, d doc.Document) (err error) { d.Revised = d.Created // put same time in both fields _, err = ctx.Transaction.Exec(` - INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc as excerpt, c_slug, c_tags, c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised) + INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc, c_slug, c_tags, c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, d.RefID, d.OrgID, d.SpaceID, d.UserID, d.Job, d.Location, d.Name, d.Excerpt, d.Slug, d.Tags, d.Template, d.Protection, d.Approval, d.Lifecycle, d.Versioned, d.VersionID, d.VersionOrder, d.GroupID, d.Created, d.Revised) @@ -312,7 +312,7 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64, // Remove document pages, revisions, attachments, updates the search subsystem. func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error) { b := mysql.BaseQuery{} - rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section WHERE _cdocid IN (SELECT c_refid FROM dmz_doc WHERE c_spaceid=\"%s\" AND c_orgid=\"%s\")", spaceID, ctx.OrgID)) + rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section WHERE c_docid IN (SELECT c_refid FROM dmz_doc WHERE c_spaceid=\"%s\" AND c_orgid=\"%s\")", spaceID, ctx.OrgID)) if err != nil { return @@ -333,7 +333,7 @@ func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows in return } - return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, spaceID) + return b.DeleteConstrained(ctx.Transaction, "dmz_doc", ctx.OrgID, spaceID) } // GetVersions returns a slice containing the documents for a given space. diff --git a/domain/group/mysql/store.go b/domain/group/mysql/store.go index 954a13d5..5aa84ec7 100644 --- a/domain/group/mysql/store.go +++ b/domain/group/mysql/store.go @@ -159,7 +159,7 @@ func (s Scope) GetMembers(ctx domain.RequestContext) (r []group.Record, err erro SELECT a.id, a.c_orgid AS orgid, a.c_groupid AS groupid, a.c_userid AS userid, b.c_name As name, b.c_desc AS purpose FROM dmz_group_member a, dmz_group b - WHERE a.c_orgid=? AND a.c_groupid=b.refid + WHERE a.c_orgid=? AND a.c_groupid=b.c_refid ORDER BY a.c_userid`, ctx.OrgID) diff --git a/domain/link/mysql/store.go b/domain/link/mysql/store.go index 4663970c..a9f4e43e 100644 --- a/domain/link/mysql/store.go +++ b/domain/link/mysql/store.go @@ -160,10 +160,10 @@ func (s Scope) SearchCandidates(ctx domain.RequestContext, keywords string) (doc // find matching documents temp := []link.Candidate{} keywords = strings.TrimSpace(strings.ToLower(keywords)) - likeQuery := "LOWER(c_name) LIKE '%" + keywords + "%'" + likeQuery := "LOWER(d.c_name) LIKE '%" + keywords + "%'" err = s.Runtime.Db.Select(&temp, ` - SELECT d.c_refid AS documentid, d.c_spaceid AS spaceid, d.c_name, l.c_name AS context + SELECT d.c_refid AS documentid, d.c_spaceid AS spaceid, d.c_name AS title, l.c_name AS context FROM dmz_doc d LEFT JOIN dmz_space l ON d.c_spaceid=l.c_refid WHERE l.c_orgid=? AND `+likeQuery+` AND d.c_spaceid IN (SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN @@ -237,11 +237,11 @@ func (s Scope) SearchCandidates(ctx domain.RequestContext, keywords string) (doc } // find matching attachments - likeQuery = "LOWER(a.filename) LIKE '%" + keywords + "%'" + likeQuery = "LOWER(a.c_filename) LIKE '%" + keywords + "%'" temp = []link.Candidate{} err = s.Runtime.Db.Select(&temp, ` - SELECT a.c_refid AS targetid, a.c_docid AS documentid, a.c_filename AS title, a.c_extension AS context, d.c_spaceiid AS spaceid + SELECT a.c_refid AS targetid, a.c_docid AS documentid, a.c_filename AS title, a.c_extension AS context, d.c_spaceid AS spaceid FROM dmz_doc_attachment a LEFT JOIN dmz_doc d ON d.c_refid=a.c_docid WHERE a.c_orgid=? AND `+likeQuery+` AND d.c_spaceid IN (SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN diff --git a/domain/page/mysql/store.go b/domain/page/mysql/store.go index 4c7108ef..24038b2c 100644 --- a/domain/page/mysql/store.go +++ b/domain/page/mysql/store.go @@ -197,7 +197,7 @@ func (s Scope) Update(ctx domain.RequestContext, page page.Page, refID, userID s // It then propagates that change into the search table, adds a delete the page revisions history, and audits that the page has been removed. func (s Scope) Delete(ctx domain.RequestContext, documentID, pageID string) (rows int64, err error) { b := mysql.BaseQuery{} - rows, err = b.DeleteConstrained(ctx.Transaction, "page", ctx.OrgID, pageID) + rows, err = b.DeleteConstrained(ctx.Transaction, "dmz_section", ctx.OrgID, pageID) if err == nil { _, _ = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section_meta WHERE c_orgid='%s' AND c_sectionid='%s'", ctx.OrgID, pageID)) diff --git a/domain/search/mysql/store.go b/domain/search/mysql/store.go index ccf23581..4100f4b4 100644 --- a/domain/search/mysql/store.go +++ b/domain/search/mysql/store.go @@ -226,7 +226,7 @@ func (s Scope) matchFullText(ctx domain.RequestContext, keywords, itemType strin WHERE s.c_orgid = ? AND s.c_itemtype = ? - AND s.c_docid = d.refid + AND s.c_docid = d.c_refid AND d.c_spaceid IN ( SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN diff --git a/gui/app/styles/view/search.scss b/gui/app/styles/view/search.scss index e1d84197..177f96cf 100644 --- a/gui/app/styles/view/search.scss +++ b/gui/app/styles/view/search.scss @@ -107,7 +107,7 @@ > .syntax { - margin: 20px; + margin: 20px 0; > .example { margin-top: 10px; diff --git a/server/server.go b/server/server.go index 0331197f..af0d52c4 100644 --- a/server/server.go +++ b/server/server.go @@ -30,7 +30,7 @@ var testHost string // used during automated testing // Start router to handle all HTTP traffic. func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) { - rt.Log.Info(fmt.Sprintf("Edition: %s version %s", rt.Product.Title, rt.Product.Version)) + rt.Log.Info(fmt.Sprintf("Product: %s version %s", rt.Product.Title, rt.Product.Version)) // decide which mode to serve up switch rt.Flags.SiteMode {