Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:37:27+00:00 2026-05-22T21:37:27+00:00

Last year, my group developed a web service that included basic search functionality. All

  • 0

Last year, my group developed a web service that included basic search functionality.
All search conditions where combined with a boolean AND:

<conditions>
  <condition name="name1">value1</condition>
  <condition name="name2">value2</condition>
<conditions>

… is equivalent to name1=value1 AND name2=value2 etc.

Now, we have been asked to expand the search feature to allow for more complex searches.
I see two plausible approaches:

OPTION #1: Let users pass in their own SQL query (either full clause, or just the ‘where).

Examples:

<where>Cost = 5000.00 OR Cost > 5000.00</where>
<query>SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '%test%'</query>

Precedent:

  • SearchSQL.SetWhereClause in IBM’s FileNet API
  • Content Management Interoperability Services (CMIS) spec
  • ADO uses this approach in various places. For example, recordset.Filter

Advantages:

  • Our schema stays simple. We could leave the “<conditions>” approach in place for the simple use cases, and add an alternative syntax.
  • We’d just use the WHERE clause directly server-side (after scrubbing for sql injection) == cleaner code server side
  • Follows industry standards (does it? CMIS, Microsoft … anything from the Java world?)

Disadvantages:

  • Not exactly “elegant xml” (is there any such thing?). Potentially forces consumers of the service to do some hackish string manipulation on their side, rather than providing them with something more elegant.

OPTION #2. Revamp our <conditions> approach to allow more granular queries in the soap request.

Example (from FetchXML):

 <filter type='and'> 
     <condition attribute='lastname' operator='ne' value='Cannon' /> 
 </filter> 

Precedent:

  • FetchXML
  • Ant gets close with <if> / <else>

Advantages:

  • Arguably more consistent with what an end user would expect (often the mark of a good API)
  • Potential to give end users cleaner code
  • Doesn’t create dependency on SQL language / backend. Keeps it abstract

Disadvantages:

  • More server-side code required to reconstruct the XML into the SQL statement the user meant in the first place

I hope that the examples, precedent, advantages, and disadvantages give enough background to avoid subjective answers. I am looking for answers grounded in standards and best practices.

My question is: are there definitive reasons for choosing one approach over the other in expanding an API?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:37:28+00:00Added an answer on May 22, 2026 at 9:37 pm

    Option #2, if only for one reason: security.

    Allowing end users to pass arbitrary SQL to your database is an invitation to disaster. You either trust your users to NEVER make mistakes in SQL, or you have to write code to determine which SQL you’re going to accept and which SQL you’re going to reject.

    Option #2 will be harder to design and implement, but option #1 guarantees that you will hate yourself at some point when some user updates every record in an important table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Last year, Scott Guthrie stated You can actually override the raw SQL that LINQ
I've noticed that just in the last year or so, many major websites have
I took a data structures class in C++ last year, and consequently implemented all
This XML file contained archived news stories for all of last year. I was
I designed a small website last year in visual web developer. I added a
Last year I made an Android application that scrapped the informations on my train
I began using Git last year and have enjoyed it so much that I'm
I have implemented semaphores in Linux last year. But for that I have to
Within the last year I have become addicted to subversion. I am an only
First a little intro: Last year i wrote this http://dragan.yourtree.org/code/canvas-3d-graph/ Now, i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.